zoukankan      html  css  js  c++  java
  • sql积累

    1.在流水表多条数据中分页查询最新的一条

    SELECT tt.*
    FROM myTable tt
    INNER JOIN
        (SELECT ID, MAX(Date) AS MaxDateTime
        FROM myTable
        GROUP BY ID) groupedtt 
    ON tt.ID = groupedtt.ID 
    AND tt.Date = groupedtt.MaxDateTime

     2.查询表中每列不为空的条数

    select count(case when mac!='' then '1' end) as
            macCount,
            count(case
            when phone!='' then '1' end) as phoneCount,count(case when
            imei!=''
            then '1' end) as imeiCount,count(case when imsi!='' then '1'
            end) as
            imsiCount from basic_resources_info_cluster where toDate(time) =
            #{createDate}
  • 相关阅读:
    蟠桃记
    考新郎
    有假币
    年会抽奖
    发邮件
    进制回文数
    数位和
    外星人的语言
    一的个数
    继承
  • 原文地址:https://www.cnblogs.com/lgjava/p/13902729.html
Copyright © 2011-2022 走看看