CREATE TABLE Goods(Store VARCHAR(255), Food VARCHAR(255), Amount INT);
INSERT INTO Goods(Store, Food, Amount)
VALUES
('Store 1', 'potato', 50),
('Store 5', 'potato', 150),
('Store 12', 'potato', 300),
('Store 1', 'tomato', 220),
('Store 5', 'tomato', 180),
('Store 12', 'tomato', 60),
('Store 1', 'cucumber', 500),
('Store 5', 'cucumber', 10),
('Store 12', 'cucumber', 90);
SELECT
Store,
SUM(CASE WHEN Food = 'potato' THEN Amount END) "potatos",
SUM(CASE WHEN Food = 'tomato' THEN Amount END) "tomato",
SUM(CASE WHEN Food = 'cucumber' THEN Amount END) "cucumbers"
FROM Goods
GROUP BY Store;