transpose columns to rows

后端 未结 1 984
刺人心
刺人心 2021-01-19 05:32

The following query is working as expected.

But how do I get the results in rows those are displayed in columns?

select curdate() AS one, 
date_sub(         


        
相关标签:
1条回答
  • 2021-01-19 06:25

    You can use UNION ALL for this

    select 'one' as label,  curdate() as val
    UNION ALL
    select 'two' as label,  date_sub(curdate(), interval 15 day) as val
    UNION ALL
    select 'three' as label,  date_sub(curdate(), interval 30 day)  as val
    UNION ALL
    select 'four' as label,  date_sub(curdate(), interval 45 day) as val
    UNION ALL
    select 'five' as label,  date_sub(curdate(), interval 60 day) as val
    UNION ALL
    select 'six' as label,  date_sub(curdate(), interval 75 day)  as val
    UNION ALL
    select 'seven' as label,  date_sub(curdate(), interval 90 day) as val
    
    0 讨论(0)
提交回复
热议问题