如果我可以使用此查询 -
SELECT country,
SUM(IF(product= 'product1', 1,0)) AS `product1`,
SUM(IF(product= 'product2', 1,0)) AS `product2`,
SUM(IF(product= 'product3', 1,0)) AS `product3`,
SUM(IF(product= 'product4', 1,0)) AS `product4`,
SUM(IF(product= 'product5', 1,0)) AS `product5`,
COUNT(*) AS total FROM table
group by country
给我一个这样的结果 -
Product 1 Product 2 Product 3 Total etc...
France 103 99 78 280
Spain 60 22 13 95
Germany 33 77 30 130
我可以添加什么来查询给我一个垂直总数ie -
Product 1 Product 2 Product 3 Total etc...
All Countries ? ? ? ?
France 103 99 78 280
Spain 60 22 13 95
Germany 33 77 30 130
我目前在收到查询后在PHP中执行此操作但是必须有一种方法可以在查询中执行此操作吗?