SELECT *
FROM student
Output:-
Pivoting Query :-
select student_id, isnull(Student1,'') as St1,isnull(Student2,'') as St2,isnull(Student3,'') as St3,
isnull(Student4,'') as St4,isnull(Student5,'') as St5 from
(SELECT student_id, Student1,Student2,Student3,Student4,Student5
FROM (
SELECT *
FROM student) up
PIVOT (SUM(Marks) FOR Student_name IN (Student1,Student2,Student3,Student4,Student5)) AS pvt
) ds1 ORDER BY student_id
OutPut :-
--SELECT eMP_ID,cALL_sTATUS_ID,isnull([1],0) AS R1,Isnull([2],0) --AS R2,ISNULL([3],0) AS R3,ISNULL([4],0) AS R4,ISNULL([5],0) AS --R5 FROM
--(select (SELECT eMP_ID FROM CALL WHERE CALL_ID=C.cALL_ID) AS --eMP_ID,
--CALL_ID,(SELECT CALL_sTATUS_ID FROM CALL WHERE --CALL_ID=C.cALL_ID) AS cALL_sTATUS_ID
--,count(*) AS CALLS
--from cALL C
--group by CALL_ID)
--P PIVOT ( SUM(CALLS) FOR CALL_id IN([1],[2],[3],[4],[5])) AS --pvt
No comments:
Post a Comment