I have a table like:
Table1
---------------------
Id |Kind1|Kind2|Kind3|
---------------------
1 | 2 | 2 | 3 | *
---------------------
2 | 2 | 2 | 2 | +
---------------------
3 | 2 | 2 | 1 |
---------------------
4 | 2 | 2 | 3 | *
---------------------
5 | 2 | 1 | 1 |
---------------------
6 | 1 | 1 | 1 |
---------------------
7 | 2 | 2 | 2 | +
----------------------
And I want to get that result as shown below Id’s have to generate automaticaly
I have to get count of same row group
Result
------------------------------
Id | Count |New1 |New2 |New3 |
------------------------------
1 | 2 | 2 | 2 | 2 |
------------------------------
2 | 2 | 2 | 2 | 3 |
------------------------------
3 | 1 | 2 | 2 | 1 |
------------------------------
4 | 1 | 2 | 1 | 1 |
------------------------------
5 | 1 | 1 | 1 | 1 |
------------------------------
How can I do that in sql server?
1 Answer