Solved

Counting number of returned rows from a query

Posted on 2012-04-13
3
237 Views
Last Modified: 2012-04-13
I am running this query

select distinct DATEname(YYYY,Created_Date) + ' ' +datename(mm,Created_Date) +  ' ' + DATEname(dd,Created_Date)' Days Logged In'
 from Session_Logons where User_ID = 13

which returns a row for each day a login to an application was recorded (there may have been multiple login on a given day, but I only want to record the fact that a login occurred on a given day. Therefore the rows returned are as follows

2010 November 9
2010 November 6
2010 October 31
etc

How can I modify this to give me just a count of the total number of rows, i.e. how many days in total a login was made
0
Comment
Question by:Diane Lonergan
[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
  • 2
3 Comments
 
LVL 8

Assisted Solution

by:X-treem
X-treem earned 250 total points
ID: 37841764
try select count(disctinct ...
0
 
LVL 8

Expert Comment

by:X-treem
ID: 37841768
ps: depending on the program language and sql there are built in functions,
eg php mysql_num_rows
0
 
LVL 18

Accepted Solution

by:
deighton earned 250 total points
ID: 37841806
SELECT COUNT(0) AS NoRows FROM (select distinct DATEname(YYYY,Created_Date) + ' ' +datename(mm,Created_Date) +  ' ' + DATEname(dd,Created_Date)' Days Logged In'
 from Session_Logons where User_ID = 13) AS T
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

734 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