Saint Nick
Lifer
Here is my query:
I want to compare the columns LastLE01 and LastCDL1. As you may notice, I have the following like in my WHERE clause:
However, is SQL joining on these? I want it to be treated as a compare statement, but is it treating it as a join? The goal is to output where c.Qlfn_Code = 'LE01' AND WHERE LastCDL1 >= LastLE01.
Thanks!
Code:
SELECT TOP 100 PERCENT c.Empl_Nbr, c.Qlfn_Code as CurrentQlfn_Code, c.CDL, a.Qlfn_CodeDate as LastLE01, b.Qlfn_CodeDate as LastCDL1
FROM DVMS_Main as c,
/*LE01 Query*/
(
SELECT DVMS_LicHist.Empl_Nbr, DVMS_LicHist.Qlfn_Code, max(DVMS_LicHist.EntryDate) as Qlfn_CodeDate
FROM DVMS_LicHist
WHERE DVMS_LicHist.Qlfn_Code = 'LE01'
GROUP BY DVMS_LicHist.Empl_Nbr, DVMS_LicHist.Qlfn_Code
/*ORDER BY DVMS_LicHist.Empl_Nbr*/
) as a,
/*CDL1 Query*/
(
SELECT DVMS_LicHist.Empl_Nbr, DVMS_LicHist.Qlfn_Code, max(DVMS_LicHist.EntryDate) as Qlfn_CodeDate
FROM DVMS_LicHist
WHERE DVMS_LicHist.Qlfn_Code = 'CDL1'
GROUP BY DVMS_LicHist.Empl_Nbr, DVMS_LicHist.Qlfn_Code
/*ORDER BY DVMS_LicHist.Empl_Nbr*/
) as b
WHERE c.Empl_Nbr = a.Empl_Nbr
AND c.Empl_Nbr = b.Empl_Nbr
AND c.Qlfn_Code = 'LE01'
AND b.Qlfn_CodeDate >= a.Qlfn_CodeDate
AND c.CDL IS NOT NULL
AND c.CDL <> ' '
AND c.CDL <> 'O'
AND c.CDL <> 'C'
AND c.CDL <> 'D'
AND c.ActiveFlag = 'Y'
ORDER BY c.Empl_Nbr
I want to compare the columns LastLE01 and LastCDL1. As you may notice, I have the following like in my WHERE clause:
Code:
AND b.Qlfn_CodeDate >= a.Qlfn_CodeDate
However, is SQL joining on these? I want it to be treated as a compare statement, but is it treating it as a join? The goal is to output where c.Qlfn_Code = 'LE01' AND WHERE LastCDL1 >= LastLE01.
Thanks!