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.
Author |
Topic |
Adreanne
Starting Member
9 Posts |
Posted - 2007-05-03 : 09:13:12
|
I would like to take the following code and display the data / count by month. I want to see how many people are logging in by month.. I tried using the datepart but I keep getting an aggrefate comannd error can anyone help modify this querySELECT DISTINCT Count(login.login_time) AS CountOflogin_timeFROM loginWHERE login.login_time>=#10/1/2005#;Thanks, |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-05-03 : 09:15:44
|
SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, Login_Time), 0) AS Month, COUNT(*) AS CntFROM LoginWHERE Login_Time >= '20051001'GROUP BY DATEADD(MONTH, DATEDIFF(MONTH, 0, Login_Time), 0)ORDER BY 1Peter LarssonHelsingborg, Sweden |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-05-03 : 09:19:40
|
SELECT YEAR(Login_Time) AS Year, MONTH(Login_Time) AS Month, COUNT(*) AS CntFROM LoginWHERE Login_Time >=#10/1/2005#GROUP BY YEAR(Login_Time), MONTH(Login_Time)--ORDER BY YEAR(Login_Time), MONTH(Login_Time)Peter LarssonHelsingborg, Sweden |
 |
|
Adreanne
Starting Member
9 Posts |
Posted - 2007-05-03 : 09:22:04
|
Thanks a bunch for the code. However, I put the code in and I got an error it says:Circular reference caused by Alias Month in query definition's Select List |
 |
|
Adreanne
Starting Member
9 Posts |
Posted - 2007-05-03 : 09:24:03
|
IT WORKED YOU ARE A LIFE SAVER PESO! |
 |
|
|
|
|
|
|