Hello all,
I am in need of solution to the following,
I;ve data as below. Original table got nearly 90 columns of such values. Here I just gave 13 columns as example.
ID | Name | Med1 | Med2 | Med3 | Med4 | Med5 | Med6 | Med7 | Med8 | Med9 | Med10 | Med11 | Med12 | Med13 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Ramila | 1 | 1 | |||||||||||
2 | Pravena | 4 | 3 | |||||||||||
3 | Vikram | 1 | 4 | |||||||||||
4 | Amra sava | 4 | 4 | |||||||||||
5 | Pintuladuram | 3 | 6 | |||||||||||
6 | Punisurma | 1 | 3 | 6 | ||||||||||
7 | Meena | 1 | 6 | 6 | ||||||||||
8 | Reshma | 2 | 4 | |||||||||||
9 | Kana | 1 | 6 |
Need a query to display the result as below,
ID | Name | Med | Number |
---|---|---|---|
1 | Ramila | Med1 | 1 |
1 | Ramila | Med6 | 1 |
2 | Pravena | Med3 | 3 |
2 | Pravena | Med9 | 3 |
3 | Vikram | Med1 | 1 |
3 | Vikram | Med3 | 3 |
4 | Amra sava | Med3 | 3 |
4 | Amra sava | Med9 | 3 |
5 | Pintuladuram | Med7 | 3 |
5 | Pintuladuram | Med13 | 6 |
6 | Punisurma | Med1 | 1 |
6 | Punisurma | Med4 | 3 |
6 | Punisurma | Med11 | 6 |
7 | Meena | Med1 | 1 |
7 | Meena | Med11 | 6 |
7 | Meena | Med13 | 6 |
8 | Reshma | Med2 | 2 |
8 | Reshma | Med6 | 4 |
9 | Kana | Med1 | 1 |
9 | Kana | Med11 | 6 |
Is it possible to derive using MS SQL? If so please help me. - Thank you!