October 19, 2009 at 8:12 am
Good morning all,
Just about every query I worked I need to combine:
Query 1
select DATEADD(wk, DATEDIFF(wk, 0, Record_date), 0) AS Weekly_Repair, count(e.Disposition_ID) AS Repair
from tbl_Assembly_holds e
WHERE e.Disposition_ID <> '1' and Record_date Between '9/7/2009' and '9/28/2009'
GROUP BY DATEADD(wk, DATEDIFF(wk, 0, Record_date), 0)
ORDER BY Weekly_Repair
Query 2
SELECT DATEADD(wk, DATEDIFF(wk, 0, DateProd), 0) AS Weekly_Production, sum(UnitsProd) AS Total_Units
FROM tbl_Assembly_Production
WHERE dateProd Between '9/7/2009' and '9/28/2009'
GROUP BY DATEADD(wk, DATEDIFF(wk, 0, DateProd), 0)
ORDER BY Weekly_Production
Query 3
select sum(unitsprod) as Totals
from tbl_assembly_production
WHERE dateProd Between '9/7/2009' and '9/28/2009'
Query 4
select count(Disposition_ID) As rpTotals
from tbl_assembly_holds
WHERE Disposition_ID <> '1' and Record_date Between '9/7/2009' and '9/28/2009'
Query 5
select tbl_Assembly_holds.record_date,
sum(case when shift = 1 then 1 else 0 end) Shift_1,
sum(case when shift = 2 then 1 else 0 end) Shift_2,
sum(case when shift = 3 then 1 else 0 end) Shift_3
from tbl_assembly_production
join tbl_assembly_holds on tbl_assembly_production.workorder = tbl_assembly_holds.workorder
join tlkp_item on tbl_assembly_production.item = tlkp_item.item
JOIN tbl_Assembly_hold_defects on tbl_assembly_holds.tagnumber = tbl_assembly_hold_defects.tagnumber
WHERE tbl_Assembly_hold_defects.defect_id = #FORM.defect# and tbl_Assembly_holds.Record_Date BETWEEN '#FORM.dateFrom#' AND '#FORM.dateTo#'
group by tbl_Assembly_holds.record_date
I need a running total then by shift totals then percentage of "good yield".
October 28, 2009 at 8:33 pm
To truely help you, more we need. Please provide the DDL (CREATE TABLE statements), sample data (INSERT INTO statements), and expected results based on sample data.
For help with this request, please read the first article I reference below in my signature block regarding asking for assistance. By following the instructions in that article you will get excellent assistance and tested code as well.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply