Solved

Get the count from my select statement?

Posted on 2012-03-13
5
345 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
5 Comments
 
LVL 20

Expert Comment

by:informaniac
Comment Utility
select @@Count
0
 

Author Comment

by:arthurh88
Comment Utility
And how do I "select @@Count?"  

Please build my new statement for me.
0
 
LVL 4

Expert Comment

by:Paul-B
Comment Utility
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
Comment Utility
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
Comment Utility
yes that worked perfectly
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now