zoukankan      html  css  js  c++  java
  • LeetCode 【困难】数据库-第618:学生地理信息报告(分组行列转换)

    题目要求

    1. 按照’月份‘排序

    select *,row_number() over (partition by continent order by name) rn from students;
    

    2.行列转换,找出符合条件的一个人

    select  
    min(
    case when continent = '一月' then name else  end)  as 一月,
    min(
    case when continent = '二月' then name else null end)  as 二月,
    min(
    case when continent = '三月' then name else null end)  as 三月,
    min(
    case when continent = '四月' then name else null end)  as 四月
    from students;
    

    3. 汇总集合

    select  
    min(
    case when continent = '一月' then name else null end)  as 一月,
    min(
    case when continent = '二月' then name else null end)  as 二月,
    min(
    case when continent = '三月' then name else null end)  as 三月,
    min(
    case when continent = '四月' then name else null end)  as 四月
    from (
    select *,row_number() over (partition by continent order by name) rn from students
    ) b
    group by rn;
    

  • 相关阅读:
    WPF 中 TextBlock 文本换行与行间距
    WPF中TextBox文件拖放问题
    WPF 自定义鼠标光标
    矩形覆盖
    跳台阶和变态跳台阶
    用两个栈实现队列
    重建二叉树
    从尾到头打印链表
    替换空格
    斐波那契数列
  • 原文地址:https://www.cnblogs.com/Tdazheng/p/14962640.html
Copyright © 2011-2022 走看看