I have the following SQL:
select jobtran.trans_date
,job.job
,job.suffix
,job.item
,jobtran.wc
,Sum(jobtran.qty_complete) as Gross_qty
,(Select top 1 qty_complete as Net_Qty from GAI_Previous_Job_Info where GAI_Previous_Job_Info.job = job.job and
GAI_Previous_Job_Info.suffix = job.suffix - 1) as net_qty
,(Select top 1 unit_weight from GAI_Previous_Job_Info where GAI_Previous_Job_Info.job = job.job and
GAI_Previous_Job_Info.suffix = job.suffix - 1) as unit_weight
,Sum(CASE When jobtran.trans_type = 'C' Then a_hrs Else 0 End) as run_hrs
from job,jobtran
where jobtran.wc BETWEEN @WCStart and @WCEND and jobtran.trans_date BETWEEN @PStartingTranDate and @PEndingTranDate
and jobtran.job = job.job and jobtran.suffix = job.suffix
and jobtran.trans_type in('R','C')
group by jobtran.trans_date,job.job,job.suffix,job.item,jobtran.wc
order by jobtran.wc
When I have multiple transactions such as two different transaction dates or the same date at a different time i get net_qty repeated is there anyway to avoid this??