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 |
|
mike123
Master Smack Fu Yak Hacker
1462 Posts |
Posted - 2007-08-30 : 17:38:20
|
| Hi,I have the following table below, and I want to bring back a query that shows how many logs per day. I'm getting confused on how to group by on the date, any advice is much appreciated.Thanks very much!! mike123The resultset would look something like thislogDate/Count/Description08/08/07 / 40000 / sent08/08/07 / 10 / failed08/07/07 / 30000 / sent08/07/07 / 51 / failedCREATE TABLE [dbo].[tblMatchSendLog]( [LogID] [int] IDENTITY(1,1) NOT NULL, [LogDate] [datetime] NOT NULL, [UserID] [int] NOT NULL, [Description] [nvarchar](250) NULL) ON [PRIMARY] |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-30 : 17:49:59
|
SELECT LogDate, COUNT(*), DescriptionFROM tblMatchSendLogGROUP BY LogDate, DescriptionORDER BY LogDate, 2 DESC E 12°55'05.25"N 56°04'39.16" |
 |
|
|
mike123
Master Smack Fu Yak Hacker
1462 Posts |
Posted - 2007-08-30 : 18:11:35
|
| Hey Peso,Sorry I didnt explain that completely right, my problem is that I am getting 100,000's of dates because its grouping each date by the second. I would like it just grouped by the actual DAY.much appreciated, once again :) thx,mike123 |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2007-08-30 : 18:15:03
|
| [code]SELECT dateadd(dd,datediff(dd,0,LogDate),0) as LogDate, COUNT(*), DescriptionFROM tblMatchSendLogGROUP BY dateadd(dd,datediff(dd,0,LogDate),0), DescriptionORDER BY dateadd(dd,datediff(dd,0,LogDate),0), COUNT(*) desc[/code]CODO ERGO SUM |
 |
|
|
mike123
Master Smack Fu Yak Hacker
1462 Posts |
Posted - 2007-08-30 : 18:28:13
|
| awesome thanks so much!! :) |
 |
|
|
|
|
|
|
|