If I understood you correctly you are comparing Record_ID to Phase_ID
try this:
SELECT rx.* FROM records rr LEFT JOIN records rx ON rr.Record_ID=rx.Phase_ID
WHERE rr.Record_Date>@date1 && rr.Record_Date<@date2
&& NOT (rx.Record_Date>@date3 && rx.Record<@date4);
This assumes that @date1, @d
If I understood you correctly you are comparing Record_ID to Phase_ID
try this:
SELECT rx.* FROM records rr LEFT JOIN records rx ON rr.Record_ID=rx.Phase_ID
WHERE rr.Record_Date>@date1 && rr.Record_Date<@date2
&& NOT (rx.Record_Date>@date3 && rx.Record<@date4);
This assumes that @date1, @d
If I understood you correctly you are comparing Record_ID to Phase_ID
try this:
SELECT rx.* FROM records rr LEFT JOIN records rx ON rr.Record_ID=rx.Phase_ID
WHERE rr.Record_Date>@date1 && rr.Record_Date<@date2
&& NOT (rx.Record_Date>@date3 && rx.Record<@date4);
This assumes that @date1, @d
I'm trying to figure out the bloody hell you're looking for.
What is date3? Where does it come from?
I think I speak for most folks here when I say...
What is date4? Where does it come from?
What is date4? Where does it come from?
Why is record 2 good, but not record 3?
How does Phase enter i