Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Modify to show current month only

Author  Topic 

Adreanne
Starting Member

9 Posts

Posted - 2007-05-03 : 09:38:03
how would i take the query and show just the current months unique logins

SELECT DISTINCT YEAR(Login_Time) AS Year, MONTH(Login_Time) AS Month, COUNT(*) AS Login_Cnt
FROM Login
WHERE Login_Time >=#10/1/2005#
GROUP BY YEAR(Login_Time), MONTH(Login_Time)
ORDER BY YEAR(Login_Time), MONTH(Login_Time)

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-05-03 : 09:41:23
If you have more MS Access questions, please post them in the MS Access forum.

SELECT YEAR(Login_Time) AS Year, MONTH(Login_Time) AS Month, COUNT(*) AS Login_Cnt
FROM Login
WHERE YEAR(Login_Time) = YEAR(NOW) AND MONTH(Login_Time) = MONTH(NOW)


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-05-05 : 04:20:36
quote:
Originally posted by Peso

If you have more MS Access questions, please post them in the MS Access forum.

SELECT YEAR(Login_Time) AS Year, MONTH(Login_Time) AS Month, COUNT(*) AS Login_Cnt
FROM Login
WHERE YEAR(Login_Time) = YEAR(NOW) AND MONTH(Login_Time) = MONTH(NOW)


Peter Larsson
Helsingborg, Sweden


You missed Group by

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -