--存储过程可以
create proc p_qry
as
set nocount on
declare @s nvarchar(4000)
set @s=''
select @s=@s+','+quotename(account_no)
+'=isnull(rtrim(max(case account_no when '
+quotename(account_no,'''')
+' then ben_debit end)),'''')'
from 表 group by account_no
exec('select voucher_no'+@s+' from 表 group by voucher_no')
create proc p_qry
as
set nocount on
declare @s nvarchar(4000)
set @s=''
select @s=@s+','+quotename(account_no)
+'=isnull(rtrim(max(case account_no when '
+quotename(account_no,'''')
+' then ben_debit end)),'''')'
from 表 group by account_no
exec('select voucher_no'+@s+' from 表 group by voucher_no')
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货