原表数据:
实现结果:
脚本:
select a.PickDate,a.UserId,a.Apple from [dbo].[AppleBasket] cross apply ( values (PickDate,UserId,Apple1), (PickDate,UserId,Apple2), (PickDate,UserId,Apple3) ) a (PickDate,UserId,Apple)
原表数据:
实现结果:
脚本:
select a.PickDate,a.UserId,a.Apple from [dbo].[AppleBasket] cross apply ( values (PickDate,UserId,Apple1), (PickDate,UserId,Apple2), (PickDate,UserId,Apple3) ) a (PickDate,UserId,Apple)