I have a query which returns all parts and labour lines for a particular work order. It returns all parts lines seperately, but the labour lines are repeated for each row. What I want to accomplish for a given work order, is a list of all the parts lines, followed underneath by a list of all labour lines.This is the code from the report:select h.worknumber,--- Select parts lines and charges wp.description as [charges desc], case when wp.charge_to_cust = 1 then wp.sale_price else 0 end [UnitSalePrice], isnull(wp.qty,0) ItemQty, case when wp.charge_to_cust = 1 then wp.sale_price*wp.qty else 0 end [SalePrice], case when isnull(h.actual_parts_sale,0)<>0 and wp.charge_to_cust <> 0 then isnull(h.actual_parts_sale,0) when wp.charge_to_cust = 0 then 0 else isnull(h.est_parts_sale,0) end est_parts_sale,-- Select labour lines and charges wl.description as [labour desc], case when wl.charge_to_cust = 1 then wl.charge_rate else 0 end [LabUnitPrice], isnull(wl.hours,0) LabItemQty, case when wl.charge_to_cust = 1 then wl.charge_rate*wl.hours else 0 end [LabSalePrice], case when isnull(h.actual_labour_sale,0)<>0 and wl.charge_to_cust <> 0 then isnull(h.actual_labour_sale,0) when wl.charge_to_cust = 0 then 0 else isnull(h.est_labour_sale,0) end est_labour_sale From worksorderhdr hleft outer join worksorderparts wp on h.worknumber = wp.worknumberleft join worksorderlabour wl on wl.worknumber = h.worknumber
Current Output:worknumber charges desc UnitSalePrice ItemQty SalePrice est_parts_sale labour desc LabUnitPrice LabItemQty LabSalePrice est_labour_sale-------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------- ----------- --------------------- --------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------- ---------------------- ---------------------- ---------------------WA-DN-002953 OUR ENGINEER SENT TO SITE TO REPLACE THE FOLLOWING PARTS- 0.00 1 0.00 110.85 LABOUR 35.00 0.5 17.5 17.50WA-DN-002953 SED FUEL FILTER AGRI / TIER 4 25.95 1 25.95 110.85 LABOUR 35.00 0.5 17.5 17.50WA-DN-002953 FILTER A120 52.50 1 52.50 110.85 LABOUR 35.00 0.5 17.5 17.50WA-DN-002953 FILTER A124 32.40 1 32.40 110.85 LABOUR 35.00 0.5 17.5 17.50
For this example what I'd like to see is 5 lines here - the labour description and charge under charges description, unit price, qty and est_parts_sale etc, and of course, there could be more than 1 labour line.Help with modifying this code would be very much appreciated.Many thanksMartyn