Please use the SQL QUERY. I want to calculate percentage using sum from another record.
End Result should look like this:
SQL QUERY:
DECLARE @tbl_PCode table
(
ID int,
PCode VARCHAR(7),
PHours DECIMAL (16,1)
)
DECLARE @tbl_TCode table
(
ID int,
TCode VARCHAR(7),
THours DECIMAL (16,1)
)
INSERT INTO @tbl_PCode
Values
(450001,'REGC',40.00),
(450001,'OTC',10.00)
INSERT INTO @tbl_TCode
Values
(450001,'FieldC',12.00),
(450001,'ShopC',38.00)
;with cte as (
select a.ID,a.PCode, a.PHours, b.TCode as TCODE, b.thours as THours,
sum(a.phours) as "Percent" from @tbl_PCode a, @tbl_TCode b
group by a.ID,a.PCode, a.PHours, b.TCode, b.thours
)
select * from cte