merge集插入,更新,删除于一体,如果要对一个表同时进行插入,更新,删除2个或3三个操作.效率要高于单个操作. merge into tableb b --被操作表using (select id,servicepromotor,servicecmclient from tablea where servicepromotor>0) a--参照表 支持子查询on a.id=b.client --关联关系when matched --a,b表均匹配到做updatethen update set…
1.并集(UNION/UNION ALL) Oracle&SQLServer中用法一致 UNION 去重 UNION ALL 不去重 -- 去重 select * from tablea union select * from tableb -- 不去重 select * from tablea union all select * from tableb 2.交集(INTERSECT/EXISTS) Oracle&SQLServer中用法一致 INTERSECT 去重 EXISTS 不去…
知识关键词:DATE_FORMAT select DATE_FORMAT(create_time,'%Y%u') weeks,count(caseid) count from tc_case group by weeks; select DATE_FORMAT(create_time,'%Y%m%d') days,count(caseid) count from tc_case group by days; select DATE_FORMAT(create_time,'%Y%m') month…
自己做过MySQL按天,按周,按月,按时间段统计,但是不怎么满意,后来找到这位大神的博客,转载一下,谢谢这位博主的分享 知识点:DATE_FORMAT 使用示例 select DATE_FORMAT(create_time,'%Y%m%d') days,count(caseid) count from tc_case group by days; select DATE_FORMAT(create_time,'%Y%u') weeks,count(caseid) count from tc_ca…