ID Dept
1 A2 B
3 A
4 C
5 B
6 D
7 E
8 F
Result :
Dept1 Dept2 Dept3
A D FB E
C
Query :
SELECT
1 AS Deptnumber
, Dept
FROM tbl_students
WHERE Dept IN ('A', 'B', 'C')
UNION
SELECT
2 AS DeptNumber
, Dept
FROM tbl_students
WHERE Dept IN ('D', 'E')
UNION
SELECT
3 AS Deptnumber
, Dept
FROM tbl_students
WHERE Dept IN ('F')
Tidak ada komentar:
Posting Komentar