Solved

Counting number of returned rows from a query

Posted on 2012-04-13
3
211 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
  • 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
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…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

705 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

20 Experts available now in Live!

Get 1:1 Help Now