SQL to fill in missing data?

Aero11

New Member
Joined
Sep 16, 2011
Messages
34
Hello again,

I have a somewhat more difficult problem, this time.

Here is the SQL code I am working with, so far.

SELECT Wo_headc.WO_NBR AS "Work Order Number", Wo_headc.CMP_DT AS "Completion Date", Wo_sthsc.FROM_STS AS "Status", Sum(Wo_sthsc.DAYS_IN_STS) AS "Days in Status", Wo_headc.ATA_MAN_NBR AS "Manual Number", IIF((Wo_headc.ATA_MAN_NBR) Like '__-__-__','Commercial','Military') AS "M/C"
FROM Wo_headc Wo_headc, Wo_sthsc Wo_sthsc
WHERE Wo_headc.WO_NBR = Wo_sthsc.WO_NBR AND ((Wo_headc.CMP_DT>={d '2010-12-15'} And Wo_headc.CMP_DT<={d '2011-01-15'}))
GROUP BY Wo_headc.WO_NBR, Wo_headc.CMP_DT, Wo_sthsc.FROM_STS, Wo_headc.ATA_MAN_NBR


Basically, there are 4 status codes that must be in every work order : (ICI, CTD, NIS, and WIP). Some work orders are missing some of these status codes. What I would like is for the query to search by Work Order, and check to see if all 4 status codes are available. If they are not, I want it to add the missing codes, and populate the "Days in Status" field with 0's.

Hopefully this isn't as complex as I think it is. I'm a beginner, so I'd appreciate it if one of the resident experts here could point me in the right direction.

Thanks in advance.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,224,564
Messages
6,179,543
Members
452,924
Latest member
JackiG

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top