please see my attached below: my actual data will be store in table 1, can I create a view that display data like table 2?
Yes it is possible and it is called a UNPIVOT
For your case:
SELECT period, value, category
FROM
(SELECT VendorID, charcge,nocharge
FROM Table) p
UNPIVOT
(value FOR category IN
(charge,nocharge)
)AS unpvt;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With