34,575
社区成员
发帖
与我相关
我的任务
分享
Declare @PartID as int
set @PartID =3
select 业务订单ID,
(case @PartID when 2 THEN 领用金额1,做数金额1
when 3 THEN 领用金额2,做数金额2 end)
from table
Declare @PartID int
set @PartID =3
select
业务订单ID,领用金额=case @partid when 2 then 领用金额1 when 3 then 领用金额2 end,
做数金额=case @partid when 2 then 做数金额1 when 3 then 做数金额2 end
from
[table]
Declare @PartID int
set @PartID =3
select 业务订单ID,领用金额=case @partid when 2 then 领用金额1 when 3 then 领用金额2 end,
做数金额=case @partid when 2 then 做数金额1 when 3 then 做数金额2 end
from [table]
Declare @PartID int
set @PartID =3
select 业务订单ID,领用金额=case @partid when 2 then 领用金额1 when 2 then 领用金额2 end,
做数金额=case @partid when 2 then 做数金额1 when 2 then 做数金额2 end
from [table]
Declare @PartID int;set @PartID =3
declare @sql varchar(8000)
set @sql='select 业务订单ID,领用金额'+ltrim(@PartID-1)+
',做数金额'+ltrim(@PartID-1)+' from table'
--select @sql
/*
select 业务订单ID,领用金额2,做数金额2 from table
*/
exec(@sql)
Declare @PartID as int
set @PartID =3
select 业务订单ID,
领用金额=(case @PartID when 2 THEN 领用金额1 when 3 THEN 领用金额2 end),
做数金额=(case @PartID when 2 THEN 做数金额1 when 3 THEN 做数金额2 end)
from tb