I need you help.
I have an Interbase SQL Select query:
Select aps.fullname, aps.productvcode, aps.alccode, aps.capacity, Cast(Round(Sum(case when wp.capacity>0 then wp.quantity * wp.capacity/10 else wp.quantity * wp.capacity end),4) as DECIMAL(18,4)) as WBTotal from AP aps left join Waybill_positions wp on wp.alccode=aps.alccode where wp.alccode='0001821000001389010' group by aps.fullname, aps.productvcode, aps.alccode, aps.capacity
union all
Select aps.fullname, aps.productvcode, aps.alccode, aps.capacity, Cast(Round(Sum(case when wp.capacity>0 then wp.quantity * wp.capacity/10 else wp.quantity * wp.capacity end),4) as DECIMAL(18,4)) as WBTotal from AP aps left join Waybill_out_positions wp on wp.alccode=aps.alccode where wp.alccode='0001821000001389010' group by aps.fullname, aps.productvcode, aps.alccode, aps.capacity
But I want the value "156,9750" from the second row to be a separate column on the right beside "WBTOTAL" and have the title "WBOTOTAL"
How to do it?
You can use CTE, like below