declare @tb table(type varchar(2),cout numeric(18,4))
insert @tb
select 1,200
union all
select 2,300
union all
select 3,400
select * from @tb
declare @tb2 table(type varchar(2),cout numeric(18,4),pe numeric(18,4))
--select sum(cout) from @tb
declare @n numeric(18,4)
select @n=sum(cout) from @TB-- group by cout
select @n
insert into @tb2
select type as type,[cout] as cout,[cout]/@n as pe from @tb
select * from @tb2
根據自己的要求改動