× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I have a table that has an employee dependent relationship.
Table columns:
MbrID
key1
isDependent
StartDate
EndDate
Status
Name

Example Data:
123 blue N 01/01/2023 12/31/2023 E Sam Smith
123 blue N 01/01/2024 12/31/2024 X Sam Smith
123 blue Y 01/01/2023 12/31/2023 Olivia Smith
123 blue Y 01/01/2024 12/31/2024 Olivia Smith
789 blue N 01/01/2023 12/31/2023 E Ken Jones
789 red N 01/01/2024 12/31/2024 X Ken Jones
789 blue Y 01/01/2023 12/31/2023 Bob Jones
789 red Y 01/01/2024 12/31/2024 Bob Jones

I need to update the dependents with the related employee status. end
result looking like.
Example Date after update:
123 blue N 01/01/2023 12/31/2023 E Sam Smith
123 blue N 01/01/2024 12/31/2024 X Sam Smith
123 blue Y 01/01/2023 12/31/2023 E Olivia Smith
123 blue Y 01/01/2024 12/31/2024 X Olivia Smith
789 blue N 01/01/2023 12/31/2023 E Ken Jones
789 red N 01/01/2024 12/31/2024 X Ken Jones
789 blue Y 01/01/2023 12/31/2023 E Bob Jones
789 red Y 01/01/2024 12/31/2024 X Bob Jones

I have an sql that looks like it will join the rows together.
select a.mbrid, b.mbrid, a.key1, b.key1, a.isdependent, b.isdependent,
a.status, b.status, a.startdate, b.startdate, a.enddate, b.enddate,
a.name, b.name
from myLib.myTable a
*left* join myLib.myTable b
on a.mbrid = b.mbrid and a.key1 = b.key1 and a.startdate = b.startdate and
a.enddate = b.enddate

Can I get it to do the update to the dependent status column in the same
SQL?
Do I need to do some sort of CTE?


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.