![](/img/trans.png)
[英]How should I design a table where a row can have different columns depending on the type of row?
[英]I have single row should convert into columns
|NumberOfQuotesGenerated | 11
| TotalAmountOfQuotes | 78100
| NumberOfInvoiceGenerated | 9
| TotalAmountOfInvoice | 8222
先感谢您
您可以尝试像下面这样的Unpivot
语法
-- create table t(NumberOfQuotesGenerated int,TotalAmountOfQuotes int,NumberOfInvoiceGenerated int, TotalAmountOfInvoice int)
-- insert into t values (11, 78100, 9, 8222)
select * from
(select * from t) s
unpivot
(
data for
colname in
([NumberOfQuotesGenerated],[TotalAmountOfQuotes],[NumberOfInvoiceGenerated],[TotalAmountOfInvoice])
)up
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.