-
行列转换case语句查看全部
-
2-5 select * from( select sum(kills) as "沙僧" from a join c on a.id=c.user_id and a.name="沙僧" )a cross join( select sum(kills) as "猪八戒" from a join c on a.id=c.user_id and a.name="猪八戒" )c cross join( select sum(kills) as "孙悟空" from a join c on a.id=c.user_id and a.name="孙悟空" )b; //其中括号后面的a b c 是给select语句结果表的命名查看全部
-
case语句 CASE WHEN 条件 THEN 要取的字段 END查看全部
-
查询重复数据,保留最大ID SELECT user_name,COUNT(*) FROM user1_test GROUP BY user_name HAVING COUNT(*)>1; 删除重复数据 DELETE a FROM user1_test a JOIN( SELECT user_name,COUNT(*),MAX(id) AS id FROM user1_test GROUP BY user_name HAVING COUNT(*)>1 )b ON a.user_name = b.user_name WHERE a.id < b.id查看全部
-
DECLARE v_cnt INT; DECLARE v_timestr INT; DECLARE rowcount BIGINT; SET v_timestr = DATE_FORMAT(NOW(),'%Y%m%d'); SELECT ROUND(RAND()*100,0)+1 INTO v_cnt; START TRANSACTION; UPDATE order_seq SET order_sn = order_sn + v_cnt WHERE timestr = v_timestr; IF ROW_COUNT() = 0 THEN INSERT INTO order_seq(timestr,order_sn) VALUES(v_timestr,v_cnt); END IF; SELECT CONCAT(v_timestr,LPAD(order_sn,7,0))AS order_sn FROM order_seq WHERE timestr = v_timestr; COMMIT;查看全部
-
删除重复的数据!查看全部
-
删除重复的数据!查看全部
-
使用序列化列转行查看全部
-
行转列查看全部
-
使用case 语句来实现行列转换 SELECT SUM(CASE WHEN u.`user_name` = '八戒' THEN k.`kills` END) AS '八戒', SUM(CASE WHEN u.`user_name` = '悟空' THEN k.`kills` END) AS '悟空' , SUM(CASE WHEN u.`user_name` = '沙僧' THEN k.`kills` END) AS '沙僧' FROM xyj_user_kills k JOIN xyj_user1 u ON k.`user_id` = u.`id`;查看全部
-
g查看全部
-
行转列技巧查看全部
-
行行列转换demo查看全部
-
Bv查看全部
-
使用case 语句来实现行列转换查看全部
举报
0/150
提交
取消