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
 Other Forums
 MS Access
 What is the command for current month?

Author  Topic 

Adreanne
Starting Member

9 Posts

Posted - 2007-05-03 : 09:44:41
how would i take the query below and show just the current months unique logins and count how many times each person logged in?

SELECT DISTINCT YEAR(Login_Time) AS Year, MONTH(Login_Time) AS Month, COUNT(*) AS Login_Cnt, login_id
FROM Login
WHERE Login_Time = MONTH(Login_Time)
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:46:51
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

Adreanne
Starting Member

9 Posts

Posted - 2007-05-03 : 09:50:24
I got an error saying

I tried to execute a query that does not include the specified expression 'YEAR(LOG_TIME) as part of an aggregate function.

Will you please help me? i really appreciate it.

Thanks,
Adreanne
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-05-03 : 09:51:33
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)
GROUP BY YEAR(Login_Time), MONTH(Login_Time)


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Adreanne
Starting Member

9 Posts

Posted - 2007-05-03 : 09:54:46
THANK YOU SOOOO MUCH!

ADREANNE lIGGINS
ATLANTA, GA
Go to Top of Page
   

- Advertisement -