| List: | General Discussion | « Previous MessageNext Message » | |
| From: | lm761104 | Date: | March 1 2007 8:13am |
| Subject: | problem of the procedure migration from the SQLServer2000 to MySQL | ||
| View as plain text | |||
SQLServer2000:Item Color Quantity
-------------------- -------------------- --------------------------
Table Blue 124
Table Red 223
Chair Blue 101
Chair Red 210
SELECT CASE WHEN (GROUPING(Item) = 1) THEN 'ALL'
ELSE ISNULL(Item, 'UNKNOWN')
END AS Item,
CASE WHEN (GROUPING(Color) = 1) THEN 'ALL'
ELSE ISNULL(Color, 'UNKNOWN')
END AS Color,
SUM(Quantity) AS QtySum
FROM Inventory
GROUP BY Item, Color WITH ROLLUP
Item Color QtySum
-------------------- -------------------- --------------------------
Chair Blue 101.00
Chair Red 210.00
Chair ALL 311.00
Table Blue 124.00
Table Red 223.00
Table ALL 347.00
ALL ALL 658.00 MySQL:SELECT Item,
Color,
SUM(Quantity) AS QtySum
FROM Inventory
GROUP BY Item, Color WITH ROLLUP
Item Color QtySum
-------------------- -------------------- --------------------------
Chair Blue 101.00
Chair Red 210.00
Chair NULL 311.00
Table Blue 124.00
Table Red 223.00
Table NULL 347.00
NULL NULL 658.00 How can I replace the Grouping()
function of SQLServer 2000 in MySQL5 ?
| Thread | ||
|---|---|---|
| • problem of the procedure migration from the SQLServer2000 to MySQL | lm761104 | 1 Mar |
