`filed_name` varchar(30) DEFAULT NULL,
`val` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of tt
-- ----------------------------
INSERT INTO `tt` VALUES ('1', 'A', '11');
INSERT INTO `tt` VALUES ('1', 'B', '22');
INSERT INTO `tt` VALUES ('1', 'C', '33');
INSERT INTO `tt` VALUES ('2', 'A', '44');
INSERT INTO `tt` VALUES ('2', 'B', '55');
INSERT INTO `tt` VALUES ('2', 'C', '66');
select
max(A) A,
max(B) B,
max(C) C
from(
select id,
case filed_name when 'A' THEN val else 0 end A,
case filed_name when 'B' THEN val else 0 end B,
case filed_name when 'C' THEN val else 0 end C
FROM tt
group by id
select id,
MAX(case filed_name when 'A' THEN val ELSE 0 END ) AS 'A',
MAX(case filed_name when 'B' THEN val ELSE 0 END ) AS 'B',
MAX(case filed_name when 'C' THEN val ELSE 0 END ) AS 'C'
FROM tt
group by id
select id ,(
SELECT
GROUP_CONCAT(DISTINCT
CONCAT(
'MAX(case filed_name when ''',t.filed_name,''' THEN val ELSE 0 END ) AS ''',t.filed_name, ''''
FROM tt t
) FROM tt
结果:
Java用什么保存账号密码 java怎样保存写的程序
使用文本编辑器编写Java源代码编写应用程序,可以使用任何一个文本编辑器来编写程序的源代码,然后使用搭配的工具进行编译和运行,在这里,我将介绍一个使用简单的文本编辑器来开发一个应用程序的步骤。public class HelloJava{
public static void main(String [] args){
System.out.println("It's nice to