我有一个结构如下的表:
ID , AMOUNT
'001', 17333935.00
'005', 1883045.00
'011', 29992400.00
'015', 17547235.00
我想创建一个这样的列表:
| '001' | '005' | '011' | '015' |
| 17333935.00 | 1883045.00 | 29992400.00 | 17547235.00 |
我试图使用这个 Select 语句,但它不起作用。
SELECT col1.ROW_RPT,col1.IDUSER,col1.SUBTOT,col2.SUBTOT,col3.SUBTOT
FROM
(SELECT 'OMSET' ROW_RPT,IDUSER,Sum(ORG_QTY*ORG_PRC) SUBTOT FROM sales WHERE IDUSER='001') col1
INNER JOIN
(SELECT 'OMSET' ROW_RPT,IDUSER,Sum(ORG_QTY*ORG_PRC) SUBTOT FROM sales WHERE IDUSER='005') col2 ON col2.ROW_RPT=col1.ROW_RPT INNER JOIN
(SELECT 'OMSET' ROW_RPT,IDUSER,Sum(ORG_QTY*ORG_PRC) SUBTOT FROM sales WHERE IDUSER='011') col3 ON col3.ROW_RPT=col1.ROW_RPT INNER JOIN
(SELECT 'OMSET' ROW_RPT,IDUSER,Sum(ORG_QTY*ORG_PRC) SUBTOT FROM sales WHERE IDUSER='015') col4 ON col3.ROW_RPT=col1.ROW_RPT
如何提取上述数据?