![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
sql
暗月公子
这个作者很懒,什么都没留下…
展开
-
mysql里查询时按自定义字符串顺序排序
SELECT t.pointtype,COUNT(1) FROM `test` t GROUP BY t.pointtype ORDER BY case when t.pointtype='aa' then '1' when t.pointtype='bb' then '2' when t.pointtype='cc' then '3' when t.pointtype='dd' then '4' else t.pointtype end asc 只能排序1到9. select*fromt_...原创 2021-03-15 16:04:58 · 293 阅读 · 0 评论 -
计算 停电时长
表id VARCHAR2(256) 用户id time VARCHAR2(256) 时间 flag VARCHAR2(256) 0来电,1停电 计算 停电时长,使用了 lead函数 select t1.id,t1.time,t1.flag,t1.next_time from (select t.id id,t.time,t.flag, lead(t.time, 1, null) over(partition by t.id order by t.id) ne...原创 2020-10-27 18:22:13 · 452 阅读 · 0 评论