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 |
|
hayko98
Starting Member
29 Posts |
Posted - 2011-06-23 : 20:33:34
|
| Hi all,I am running query that breaks (groups) results down of each hour interval.SELECT datepart(hh,due_time ),due_time FROM someTable ORDER BY 1 HrBucket due_time3 2011-03-31 03:26:49.5933 2011-03-31 03:26:49.5935 2011-03-30 05:59:56.5035 2011-03-30 05:59:52.7475 2011-03-28 05:59:47.7135 2011-03-27 05:59:13.7176 2011-03-27 06:02:31.7206 2011-03-27 06:02:56.437As You can see there is nothing for HrBucket ‘4’.I need to have all HrBuckets with or without data. Is it possible?Thank you |
|
|
jfarrugia
Yak Posting Veteran
55 Posts |
Posted - 2011-06-24 : 06:12:59
|
| you could create a temp table with one column for all hours.. and create an outer join. Display ALL hours from the temp table.. that will give u due_time as NULL when HRBucket is 4Where software development knowledge meets the reader |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-06-25 : 14:03:04
|
| another way is to use a tally table to generate hour values and use it for left joining to your table.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|