Country Value Type
AU 152 IN
AU 56 OUT
IN 85 IN
CA 74 OUT
CA 98 IN
IN 89 IN
US 124 IN
UK 856 OUT
IN 35 OUT
AU 26 IN
PS 24 OUT
CN 869 OUT
答案 0 :(得分:0)
它将为您提供所有个人国家的统计数据
SELECT country,
SUM(case when type = 'IN' then 1 END) AS IN,
SUM(case when type = 'OUT' then 1 END) AS OUT
FROM table_name
GROUP BY country
它将为您提供所有个人所有国家/地区的价值
SELECT country,
SUM(case when type = 'IN' then value END) AS IN,
SUM(case when type = 'OUT' then value END) AS OUT
FROM table_name
GROUP BY country