Solved

Counting number of returned rows from a query

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Query Optimization 14 42
SQL Insert parts by customer 12 32
Need help how to find where my error is in UFD 6 27
always on switch back after failover 2 32
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
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.

776 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