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 |
Diablos
Starting Member
10 Posts |
Posted - 2015-10-29 : 12:57:23
|
Hi I'm having problems with the following count: Here is my data Bus Starting Date End Date 4561 2015-10-26 00:00:00.000 2015-10-26 00:00:00.000 4614 2015-10-28 00:00:00.000 2015-10-28 00:00:00.000 4443 2015-10-26 00:00:00.000 2015-10-28 00:00:00.000 4521 2015-10-27 00:00:00.000 2015-10-27 00:00:00.000 4615 2015-10-28 00:00:00.000 2015-10-28 00:00:00.000
I want to know the total number of bus active based on the start and end by day,the result should be - day 26 i have 2 bus active (4561 and 4443) - day 27,the result is 2 (4521 and 4443) - day 28 the result is 3 (4614,4443,4615). i've tried with between but to no result. Thanks for your help!!
|
|
vedjha
Posting Yak Master
228 Posts |
Posted - 2016-06-18 : 12:12:05
|
select count (bus), bus from table_name where EndDate between 'mm/DD/yy' and 'mm/DD/yy' group by bus having count (bus)>0
http://kiransoftech.com |
 |
|
vedjha
Posting Yak Master
228 Posts |
Posted - 2016-06-18 : 12:12:06
|
select count (bus), bus from table_name where EndDate between 'mm/DD/yy' and 'mm/DD/yy' group by bus having count (bus)>0
http://kiransoftech.com |
 |
|
|
|
|