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 |
pankaj2910
Starting Member
31 Posts |
Posted - 2014-03-24 : 14:02:57
|
let us suppose ID | companycode | year | name | State 1 | 01 | 2013 | xyz | D 1 | 01 | 2013 |abs | S 23| 02 | 2014 | age | D 2 | 01 | 2013 | XYZ | D 1 | 01 | 2013 | abh | D 7 | 13 | 2014 | adi | C 7 | 13 | 2014 | adi | C 7 | 13 | 2013 | adi | C 7 | 13 | 2014 | adi | C 7 | 13 | 2013 | adp | C 7 | 13 | 2014 | abp | Cand we want like thisID | companycode | year | countname | State 1 | 01 | 2013 | 2 | D 23| 02 | 2014 | 1 | D 1 | 01 | 2013 | 1 | s 2 | 01 | 2013 | 1 | D 7 | 13 | 2013 | 2 | C 7 | 13 | 2014 | 4 | cpankajrocks |
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2014-03-24 : 18:46:18
|
[CODE]select ID, companycode, year, count(*) countname, Statefrom MyTablegroup by ID, companycode, year, State[/CODE]===============================================================================“Everyone wants a better life: very few of us want to be better people.” -Alain de Botton |
 |
|
pankaj2910
Starting Member
31 Posts |
Posted - 2014-03-25 : 00:53:16
|
Sorry I wantID | companycode | year | countname | State1 | 01 | 2013 | 2 | D23| 02 | 2014 | 1 | D1 | 01 | 2013 | 1 | s2 | 01 | 2013 | 1 | D7 | 13 | 2013 | 2 | C7 | 13 | 2014 | 2 | cas resultpankajrocks |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2014-03-25 : 01:05:15
|
you want this ?count ( distinct name ) KH[spoiler]Time is always against us[/spoiler] |
 |
|
pankaj2910
Starting Member
31 Posts |
Posted - 2014-03-25 : 02:12:14
|
yesbut year wisepankajrocks |
 |
|
|
|
|