Here i am getting erro.
(C.ConWeight-iSNULL(Sum(I.IWeight),0)) as Pending_Weight,
with cte as(
SELECT C.ContNo,C.entrydate as EntryDate, C.ConWeight as Act_weight, C.No_Of_Bales as Act_Qty,
iSNULL(Sum(I.IWeight),0)Isu_Weight,iSNULL(Sum(i.QTY),0)Isu_QTY,(C.ConWeight-iSNULL(Sum(I.IWeight),0)) as Pending_Weight,
(C.No_Of_Bales-iSNULL(Sum(i.QTY),0)) as Pending_Qty
FROM Containerno C
inner join tbl_ContD CD
on CD.CID=C.CID
left join ConIssuance I
on I.D_ID=CD.D_ID
where C.delid is null and I.Delid is null -- and C.entrydate>'2020-12-31' and c.con_status is null
group by C.ContNo,C.Contrackno, C.ConWeight,C.No_Of_Bales,C.entrydate
)
select ROW_NUMBER() OVER (ORDER BY ContNo) AS S_No,ContNo,COnvert(varchar,EntryDate,103) Date ,Act_weight,Act_Qty,Isu_Weight,Isu_QTY,Pending_Weight,Pending_Qty from cte
where Pending_Qty>0 -- and EntryDate>'2020-12-31'
union all
Select '','','Total', Sum(isnull(cast(Act_Weight as float),0)),Sum(isnull(cast(Act_Qty as float),0)),Sum(isnull(cast(Isu_Weight as float),0)),Sum(isnull(cast(Isu_QTY as float),0)),
Sum(isnull(cast(Pending_Weight as float),0)) , Sum(isnull(cast(Pending_Qty as float),0)) from cte
where Pending_Qty>0 -- and EntryDate>'2020-12-31'