Solved

Get the count from my select statement?

Posted on 2012-03-13
5
361 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
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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how the fundamental information of how to create a table.

808 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