Hi all
Below is my table
and data
CREATE TABLE car_uploads(
location int(3),
item varchar(12),
quantity int(4)
);
INSERT INTO car_uploads (location, item, quantity) VALUES(001,'RED CAR',1);
INSERT INTO car_uploads (location, item, quantity) VALUES(002,'RED CAR',3);
INSERT INTO car_uploads (location, item, quantity) VALUES(003,'BLUE CAR',5);
INSERT INTO car_uploads (location, item, quantity) VALUES(002,'BLUE CAR',2);
INSERT INTO car_uploads (location, item, quantity) VALUES(001,'RED CAR',2);
INSERT INTO car_uploads (location, item, quantity) VALUES(002,'RED CAR',5);
below is the code where i am getting the sum of quantity column
SELECT item,
SUM(CASE WHEN location = 1 THEN quantity ELSE 0 END) location_001,
SUM(CASE WHEN location = 2 THEN quantity ELSE 0 END) location_002,
SUM(CASE WHEN location = 3 THEN quantity ELSE 0 END) location_003,
SUM(quantity) total,
FROM car_uploads
GROUP BY item,total
now i want the sum of the total (i.e. sum(quantity) as grandtotal.
please tell how to get that..