by using tables i am getting output as follows, EmpName Place Dept income A Chennai IT 20 B Chennai IT 30 C Chennai IT 40 D Chennai CSE 30 A Chennai CSE 50 B Chennai CSE 40 C Chennai CSE 10 D Chennai CSE 70 A Bangalore IT 20 B Bangalore IT 30 C Bangalore IT 40 D Bangalore IT 80 A Bangalore EEE 20 B Bangalore EEE 30 C Bangalore EEE 40 D Bangalore EEE 80 I need output as follows Place Dept A B C D Chennai IT 20 30 40 30 Chennai CSE 50 40 10 70 Bangalore IT 20 30 40 80 Bangalore EEE 20 30 40 80 can you please help me...ASAP...
select place,dept,[A],[B],[C],[D] from TableName pivot ( sum(income) for empname in ([A],[B],[C],[D]) )as pvttbl
SELECT PLACE, DEPT, A, B, C, D FROM ( SELECT EMPNAME, PLACE, DEPT, INCOME FROM EMPLOYEE )X PIVOT (SUM(INCOME) FOR EMPNAME IN (A, B, C, D)) AS PVT
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)