Mysql - >在输出中连接两行

时间:2013-04-03 16:29:39

标签: mysql

我的表格由以下内容组成

Country   | Type     |   A   |   B   |   C   |   D   | cType
------------------------------------------------------------------
Italy     | Foreign  |       |       |   C   |   D   | Commercial  
Italy     | Foreign  |   A   |   B   |       |       | Commercial
Italy     | Local    |       |       |   C   |   D   | Gov
Italy     | Local    |   A   |   B   |       |       | Gov

我想使用类型

进行如下结果的查询
Italy   | Foreign  |   A   |   B   |   C   |   D   | Commercial
Italy   | Local    |   A   |   B   |   C   |   D   | GOV

1 个答案:

答案 0 :(得分:0)

select country, type, max(A), max(B), max(C), max(D), cType
from whatever_table
group by country, type, cType