• SQL : 把特定的数据排前面 & 分别查询几组数据的最大值


    把特定的数据排前面 :

    比如说,把没有审核身份证的人排最前面,然后再按userId正序排。

    select case when idcardverified = 1 then 0 else 1 end flag,o.* from (select id,mobile,nickname,idcardverified from users where mobile = 13800000000 or nickname = '关于衣服') o order by flag asc,id asc

    分别查询几组数据的最大值:

    比如说,有同学A B C,他们传了多次坐标,要查询他们最新的坐标。

    SELECT * FROM `map_position` where ctime in (select max(ctime) from `map_position` group by userId) order by userId asc
  • 相关阅读:
    观光公交
    luogu 4779 【模板】
    最小生成树(luogu 3366)
    计算系数
    更新区间,求单点—— luogu 3368
    HDU
    HDU
    HDU
    HDU
    BFS
  • 原文地址:https://www.cnblogs.com/foxcharon/p/9288342.html
Copyright © 2020-2023  润新知