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 |
|
freephoneid
Yak Posting Veteran
52 Posts |
Posted - 2010-04-01 : 19:31:55
|
| Hi, I've a table with following info:Code VendorId CreatedOn Status1234 3 12-Aug-2009 44567 4 18-Apr-2009 53589 3 14-Aug-2009 41234 3 17-Aug-2009 48941 3 13-Aug-2009 51234 3 15-Aug-2009 4I need a query to find count of all different status for date >= 12-Aug-2009 but < 19-Aug-2009 for vendor Id = 3Please note that Code is unique across vendor id.In this case, output should be as shown:Count Status 2 4 1 5Can any one provide me query?Thanks! |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-04-01 : 19:35:13
|
[code]select count(distinct VendorID), Statusfrom atablewhere VendorID = 3and CreateOn >= '20090812'and CreateOn < '20090819'group by Status[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
freephoneid
Yak Posting Veteran
52 Posts |
Posted - 2010-04-01 : 19:40:37
|
| Hi khtan, Thanks for the super quick reply!!!!Thanks! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-02 : 03:07:43
|
quote: Originally posted by khtan
select count(distinct VendorID), Statusfrom atablewhere VendorID = 3and CreateOn >= '20090812'and CreateOn < '20090819'group by Status KH[spoiler]Time is always against us[/spoiler]
shouldnt it be select count(distinct Code), Statusfrom atablewhere VendorID = 3and CreateOn >= '20090812'and CreateOn < '20090819'group by Status as per OP's output?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-04-02 : 03:17:11
|
you are right. Thanks for the correction  KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-02 : 03:17:43
|
Welcome Tan ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|