• sql 笔记


    分组

    case when 1

    select distinct a.Branch,
    case when kultur = '硕士' then sum(num) else '0' end as 研究生学历,
    case when kultur = '本科' then sum(num) else '0' end as 大本学历,
    case when kultur = '大专' then sum(num) else '0' end as 大专学历,
    case when kultur = '中专' then sum(num) else '0' end as 中专学历,
    case when kultur = '高中' or kultur ='职高' or kultur ='中职'  then sum(num) else '0' end as 高中学历,
    case when kultur = '初中' then sum(num) else '0' end as 初中学历,
    case when kultur = '小学' then sum(num) else '0' end as 小学学历,
    case when kultur = '' or kultur is null  then sum(num) else '0' end as 未填写学历
    from( select Branch,kultur,count(*) as num 
            from tb_Stuffbusic 
         group by branch,kultur) a
    Group by a.Branch,a.kultur

    case when 2

    select Branch as 部门名称,count(branch) as 总人数,
    sum(case when kultur = '硕士' then 1 else '0' end) as 研究生学历,
    sum(case when kultur = '本科' then 1 else '0' end) as 大本学历,
    sum(case when kultur = '大专' then 1 else '0' end) as 大专学历,
    sum(case when kultur = '中专' then 1 else '0' end) as 中专学历,
    sum(case when kultur = '高中' or kultur ='职高' or kultur ='中职'  then 1 else '0' end) as 高中学历,
    sum(case when kultur = '初中' then 1 else '0' end) as 初中学历,
    sum(case when kultur = '小学' then 1 else '0' end) as 小学学历,
    sum(case when kultur = '' or kultur is null  then 1 else '0' end) as 未填写学历
    from tb_Stuffbusic         
    group by branch

    case when 3

    UPDATE tb_Stuffbusic
    SET ID = CASE WHEN LEN(ID) = 1 THEN '000'+ID
                  WHEN LEN(ID) = 2 THEN '00'+ID
                  WHEN LEN(ID) = 3 THEN '0'+ID
                  ELSE ID
                  END

    partition by

    select * from
            (
              SELECT 
                    ROW_NUMBER() over(partition by [姓名] order by [打卡时间] desc) as rowNum
                  ,[姓名]
                  ,[打卡时间]
              FROM [dbo].[打卡记录表]
            ) temp
            where temp.rowNum = 1
  • 相关阅读:
    【问题】解决python3不支持mysqldb
    《Craking the Coding interview》python实现---02
    《Craking the Coding interview》python实现---01
    python标准库--functools.partial
    Multimodal Machine LearningA Survey and Taxonomy
    概率热图的绘制--gradcam
    Pytorch 技巧总结(持续更新)
    linux教训
    Destruction and Construction Learning for Fine-grained Image Recognition----论文
    Ubuntu16.04+3090+cuda11.0+cudnnV8+pytorch-nightly
  • 原文地址:https://www.cnblogs.com/Celebrator/p/11345068.html
Copyright © 2020-2023  润新知