Hi All!
I searched and tried alot now, to figure out how to replace the name 'NULL' in a table, when I run this query:
SELECT
YEAR(orderdate) AS Years,
(CASE WHEN country = 'US' THEN 'US' ELSE 'WORLD' END) AS region,
SUM(netamount) AS TotSales
FROM orders o JOIN
customers c
ON o.customerid = c.customerid
GROUP BY (CASE WHEN country = 'US' THEN 'US' ELSE 'WORLD' END),YEAR(orderdate) WITH ROLLUP;
I get this table: http://imgur.com/pzHa8fK
I want to replace the Nulls to 'SubTotal' respectively 'GrandTotal'. I tried it with:
COALESCE(year(orderdate), 'Subtotal') years,...
and the same with 'IFNULL(...)' but instead of replacing the name, it makes an extra column with years where all the years are listed again and the NULL's
are still remaining.
Any idea?
Advance Thanks!
AVADHESH PATEL
03-Apr-2013