我有一个表存储Row Id和Col Id用于不同的项目名称和相关数量....这描述如下....
RowId ColID Value
3 2 Laptop
4 2 Mouse
4 4 80
3 4 50
我需要输出:
Value Qty
Laptop 50
Mouse 80
答案 0 :(得分:1)
SELECT a.value AS Value, b.value AS Qty
FROM
(SELECT RowId, VALUE FROM test WHERE COLID = 2 ORDER BY ROWID) a,
(SELECT RowId, VALUE FROM test WHERE COLID = 4 ORDER BY ROWID) b
WHERE a.rowid = b.rowid