I have one requirement to show data in using SQL query only.
Table name: EMP_DEPT
DEPARTMENT | EMPLOYEE | SALARY
DEPT1 | ABC | 20000
DEPT1 | MNO | 30000
DEPT1 | XYZ | 25000
DEPT2 | DEF | 42000
DEPT2 | GHI | 35000
DEPT3 | JKL | 36000
and what I am expecting result in following way
DEPARTMENT | EMPLOYEE | SALARY
DEPT1 | ABC | 20000
| MNO | 30000
| XYZ | 25000
DEPT2 | DEF | 42000
| GHI | 35000
DEPT3 | JKL | 36000
What will be the select query to print like this. Using MSSQL as DB
Thanks in advance.
You can use
ROW_NUMBER()to identify the first time a department appears, and use aCASEstatement to show the department name or blank.