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 |
mattluk
Starting Member
15 Posts |
Posted - 2013-09-29 : 22:29:19
|
Our DB server stored a lot of job records.Such as:JobID StartTime EndTime1000001 1/1/1900 17:01 1/1/1900 17:111000002 1/1/1900 17:11 1/1/1900 17:121000003 1/1/1900 17:12 1/1/1900 17:211000004 1/1/1900 17:13 1/1/1900 17:311000005 1/1/1900 17:20 1/1/1900 17:25 I would like to count by evey 10 mins.The result like thisJobID StartTime EndTime17:00 117:10 417:20 317:30 117:40 0 Anyone can give me a hand? |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2013-09-30 : 01:34:28
|
[code]SELECT dateadd(minute, datediff(minute, 0, StartTime)/10*10, 0), COUNT(*)FROM . . .GROUP BY dateadd(minute, datediff(minute, 0, StartTime)/10*10, 0)[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2013-09-30 : 07:53:10
|
http://thefirstsql.com/2010/06/23/finding-the-most-active-15-minute-time-period/- LumbagoMy blog-> http://thefirstsql.com |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2013-09-30 : 08:39:12
|
StartTime and EndTime columns should be changed to TIME datatype.ALTER TABLE dbo.Table1 ALTER COLUMN StartTime TIME(0) NOT NULLALTER TABLE dbo.Table1 ALTER COLUMN EndTime TIME(0) NOT NULL Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|
|