- Turambar
- Feb 20, 2001
-
A Túrin Turambar turun ambartanen
-
Grimey Drawer
|
You could also fill a table with the hour and minute intervals and do a simple join.
code:Create table dbo.ReportTimeInterval
(
HourStart int not null,
MinuteStart int not null,
HourEnd int not null,
MinuteEnd int not null
)
GO
insert into dbo.ReportTimeInterval
(
select
0,0,0,9 union all select
0,10,0,19 union all select
...
23,50,23,59
)
GO
SELECT
dbo.ReportTimeInterval.HourStart,
dbo.ReportTimeInterval.MinuteStart,
dbo.ReportTimeInterval.HourEnd,
dbo.ReportTimeInterval.MinuteEnd,
COUNT(content_id) AS count
FROM
`views`
inner join dbo.ReportTimeInterval
on dbo.ReportTimeInterval.HourStart <= datepart(hour,added)
and dbo.ReportTimeInterval.MinuteStart <= datepart(minute,added)
and dbo.ReportTimeInterval.HourEnd >= datepart(hour,added)
and dbo.ReportTimeInterval.MinuteEnd >= datepart(minute,added)
GROUP BY
dbo.ReportTimeInterval.HourStart,
dbo.ReportTimeInterval.MinuteStart,
dbo.ReportTimeInterval.HourEnd,
dbo.ReportTimeInterval.MinuteEnd
This is untested code, BTW. But it should give you the general idea.
|
#
¿
Dec 10, 2007 15:00
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
¿
May 2, 2024 21:34
|
|