【问题标题】:How to transpose in Oracle? [duplicate]如何在 Oracle 中转置? [复制]
【发布时间】:2021-01-06 09:49:19
【问题描述】:

我有一张桌子:

我想在 Oracle SQL 中这样写:

如何在 SQL 中编写代码?

【问题讨论】:

    标签: sql oracle pivot


    【解决方案1】:

    您可以按如下方式使用条件聚合:

    select subjid,
           max(case when status = 'most recent dose' then date end) as most_recent_dose
           max(case when status = 'second most recent dose' then date end) as second_most_recent_dose
           max(case when status = 'dosing' then date end) as dosing
      from your_table
    group by subjid
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-13
      • 2015-06-29
      相关资源
      最近更新 更多