I have spent many hours researching this problem and trying various solutions but I never quite find a suitable solution for my specific problem. I am new to SQL and some of the examples are confusing as well.
So here is my dilemma. I have a equipment table that tracks oil changes for specific units in a database. The table looks like this:
     **id   UnitID   Posted_On    Date_Completed     Note     OverDueBy**
      1 BT-109F  2019-02-04   2019-02-14       Hrs  Overdue   23 
      1 BT-108G  2020-01-17   2020-01-22       Days Overdue   12
      1 BT-122K  2020-01-02   2020-01-16       Days Overdue   12
      1 BT-109F  2019-02-04                    Days Overdue   3 
The example records above need to be created or updated by the query. The date completed is entered manually by the technician when he has completed the oil change.
What I want the query to do is, Check to see if a specific Unit has a record where the 'Date_Completed' field is empty, and if so update the 'OverDueBy' field to reflect the new value. If all the records for the specified Unit have the 'Date_Completed' fields filled in, then the query should create a new record will all fields filled in except for the 'Date_Completed' field.
Can anyone help me construct such a query?
Thanks Clan
 
     
     
    