?
Solved

Get the count from my select statement?

Posted on 2012-03-13
5
Medium Priority
?
390 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 2000 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
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.
Suggested Courses

801 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