简体   繁体   中英

Pivot table in sql server 2005

This is my record in my table

GuestName      F1    H1    F2  H2  F3   H3
Ryan Palma     1200  Room  12  SC  14   VAT
Richard Palma  1500  Room  15  SC  17   VAT
Ruth Palma     1600  Room  16  SV  18   VAT

I want an output like this

GuestName      Room  SC  VAT
Ryan Palma     1200  12  14
Richard Palma  1500  15  17
Ruth Palma     1600  16  18

How can i do this using query,

Thanks in advance, any help is appreciated

你可以试试这个

select guestname,f1 as Room,f2 as SC,f3 as VAT from table

您可以使用此查询执行此操作: -

Select GuestName, F1 as Room, F2 as SC, F3 as VAT from your_table_name;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM