create table product
(
Productid int primary key,
category varchar(20),
price int
)
insert into product values(1111,'Computers',5000),
(2222,'Electrical',4500),
(3333,'Electronics',4800),
(4444,'Mechanical',4300)
select * from product
SELECT Computers,Electrical,Electronics,Mechanical
FROM (
SELECT price,
Category FROM product
) product
PIVOT (
MAX(Price) FOR Category IN (Computers,Electrical,Electronics,Mechanical)
) Result;
Output:
No comments:
Post a Comment