Cast (100 * cast (cast (u.n um as a decimal)/cast (isnull (nullif (sum (u.n um), 0), (1) as a decimal) as a decimal (38, 2)) as varchar) + '%' as PERCENTS from
(
The select t.t ypes as types, t.i d as id, t.n um as num, t.t otal as total, (isnull (t.p ercents, 0) + isnull (t.o ffsetamount, 0)) as percents from (
Select top 100 percent t.t ypes as types, t.i d as id, the sum (t.n um) as num, sum (t.t otal), as the total sum (t.p ercents) as percents,
(case when the sum (t.p ercents) over ()!=100, then 100 - sum (t.p ercents) over () else 0 end) offsetamount from (
Select top 100 percent t.t ypes as types, t.i d as id, t.n um as num, sum (t.n um) over () as the total,
Cast (100 * cast (cast (t.n um as a decimal)/cast (sum (t.n um) over () as a decimal) as a decimal (38, 2)) as a decimal) as percents from (
Select top 100 PERCENT s.n ame as types, s.c ode as id, count (1) the as num from HZ_AS_AssumpsitItem a inner join
(select distinct iid, eid from HZ_AS_ProjectEmpRequest where eid='4038133293514762') z on Anderson, d=z.i id
Inner join on d.i sys_departmentgroup d d=Amy polumbo rojectdid inner join (select * from (select
(case when ca. Iscustom='2' then '2' when ca. Iscustom='1' then '1' end) ifdefined,
(case when cs. CertificateType='1' then '1' when cs. CertificateType='2' then '2' when
Cs. CertificateType='3' then '3'. When cs CertificateType='4' then '4' else ca. CertificateType CertificateType end),
Ca. Projectid, ca. Certificatecode, ca. Status, ca. CertificateType as CertificateType1, ca. ReturnLetter, ca. CertificateMode, ca. Sendconfirmationid,
Row_number () over (partition by left (certificatecode, 10) order by updated_time) rn from hz_certificateapply ca left join
(select distinct certificateapplyid, CertificateType from HZ_CERTIFICATESAMPLE) cs on cs. Certificateapplyid=ca. Id) c where c.r n=1) ca on ca. ProjectId=Anderson d
Inner join sys_dict s on s.c ode=ca. CertificateType and supachai panitchpakdi arent_id in (select s1. Id from sys_dict s1 where s1. Code='HZLB')
Where z.e id='4038133293514762' and iyear between cast (' 2018 'as int) and cast (' 2020' as int) and d.i d='and'
And needreport (1, 0) in group by s.n ame, s.c ode order by num desc) t) t group by t.i d, t.t ypes, t.p ercents order by num desc) t
Union ALL select da. Name, da. Code, 0, 0, the from sys_dict da where da. The parent_id in
(select s1. Id from sys_dict s1 where s1. Code='HZLB')
) u group by u.i d, u.t ypes order by cast (u.i d as bigint)
U.n um change column has been in the sum, perform error when
Selection lists the columns' u.n um 'is invalid, because the columns are not included in an aggregate function or the GROUP BY clause,
Please everybody analysis, this is what causes?
CodePudding user response:
Cast (100 * cast (cast (u.n um as a decimal) without aggregation function here