数据库行转列

sql语句

        select to_char(t.duty_date, 'YYYY-MM-DD') as duty_date,
               '441201008' as ORG_ID,
               max(decode(t.site_no, '0144004212001', t.teller_no, null)) as a0144004212001,
               max(decode(t.site_no, '0144004212002', t.teller_no, null)) as a0144004212002,
               max(decode(t.site_no, '0144004212003', t.teller_no, null)) as a0144004212003,
               max(decode(t.site_no, '0144004212004', t.teller_no, null)) as a0144004212004,
               max(decode(t.site_no, '0144004212005', t.teller_no, null)) as a0144004212005,
               max(decode(t.site_no, '0144004212006', t.teller_no, null)) as a0144004212006
          from inspect_duty t
         where 1 = 1AND t.duty_date >= sysdate
           and t.duty_date <= last_day(sysdate)
           AND t.org_id = '441201008'
         group by t.duty_date
         order by t.duty_date

你可能感兴趣的:(数据库)