Solved

Get the count from my select statement?

Posted on 2012-03-13
5
381 Views
Last Modified: 2012-03-13
I need simply the COUNT of the following statement:

SELECT       t1.UserID, t1.State, t1.City, t2.Active
FROM          City AS t1 INNER JOIN
                      members AS t2 ON t1.UserID = t2.UserID
WHERE     (t1.State = 'New York') AND (t1.City = 'New York City') AND (t2.Active = 1)


How do I do this?
0
Comment
Question by:arthurh88
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 20

Expert Comment

by:informaniac
ID: 37718302
select @@Count
0
 

Author Comment

by:arthurh88
ID: 37718315
And how do I "select @@Count?"  

Please build my new statement for me.
0
 
LVL 4

Expert Comment

by:Paul-B
ID: 37718370
SELECT COUNT(t1.UserID, t1.State, t1.City, t2.Active)
FROM          City AS t1 INNER JOIN
                      members AS t2 ON t1.UserID = t2.UserID
WHERE     (t1.State = 'New York') AND (t1.City = 'New York City') AND (t2.Active = 1)

Open in new window

0
 
LVL 7

Accepted Solution

by:
micropc1 earned 500 total points
ID: 37718410
Count takes a single parameter. The correct statement is...

SELECT       Count (*)
FROM          City AS t1 INNER JOIN
                      members AS t2 ON t1.UserID = t2.UserID
WHERE     (t1.State = 'New York') AND (t1.City = 'New York City') AND (t2.Active = 1)

Open in new window

0
 

Author Closing Comment

by:arthurh88
ID: 37718459
yes that worked perfectly
0

Featured Post

Raise the IQ of Your IT Alerts

From IT major incidents to manufacturing line slowdowns, every business process generates insights that need to reach the people required to take action. You need a platform that integrates with your business tools to create fully enabled DevOps toolchains.

You need xMatters.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question