Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

pivot and unpivot in sql

SELECT * FROM(
SELECT date,line_number,machine_number,TIME,VAL FROM(
select *
from output_tbl 
unpivot
(
  VAL
  for TIME in ([0000HR])
) uvt

)tb1 )tb3
PIVOT (
    max(VAL)
    FOR TIME IN ([0000HR])
)pvt

Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pivot #unpivot #sql
ADD COMMENT
Topic
Name
3+3 =