Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Counting number of returned rows from a query

Posted on 2012-04-13
3
Medium Priority
?
260 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 1000 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 1000 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

Technology Partners: 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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
I have a large data set and a SSIS package. How can I load this file in multi threading?
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

597 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