Solved

Counting number of returned rows from a query

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
T-SQL 10 36
SQL Server Configuration Manager WMI Error 11 21
SQL Find Carriage Return and Delete it. 3 16
SQL Error when trigger fires in SQL Server 2008 R2 6 16
Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
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 extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

821 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