inner join distinct 1

inner join distinct

SELECT valueC
FROM C
INNER JOIN
(
    SELECT DISTINCT lookupC
    FROM B INNER JOIN
    (
        SELECT DISTINCT lookupB
        FROM A
    ) 
    A2 ON B.id = A2.lookupB
) 
B2 ON C.id = B2.lookupC

Here is what the above code is Doing:
1. Get all the distinct lookupB values from A
2. Get all the distinct lookupC values from B, where the lookupB value is in the list from step 1
3. Get all the valueC values from C, where the lookupC value is in the list from step 2

Similar Posts