sql语句之多列转换成多行(cross apply用法)

原数据:

实现以下效果:

sql语句:

SELECT playday,fee
FROM [dbo].[CM_Contract] 
cross apply
(
    values
        ([FirstAmount],[PalnDay1]),
        ([SecondAmount],[PalnDay2]),
        ([ThirdAmount],[PalnDay3])
)c(fee,playday)
where playday is not null

  

posted @ 2018-01-17 14:18  张追逐  阅读(898)  评论(0编辑  收藏  举报