Hello All,
I’ve not used SQL in quite some time and am having a little trouble remembering how to do this (if I even knew in the first place).
What I need is the column records in query #1 where the DISTINCT criteria in query #2 is true.
I’ve tried a UNION, WHERE IN or EXISTS queries but with no success.
Can anyone please help me out here?
Many thanks for any/all suggestions!
- tm
Query #1
Query #2
I’ve not used SQL in quite some time and am having a little trouble remembering how to do this (if I even knew in the first place).
What I need is the column records in query #1 where the DISTINCT criteria in query #2 is true.
I’ve tried a UNION, WHERE IN or EXISTS queries but with no success.
Can anyone please help me out here?
Many thanks for any/all suggestions!
- tm
Query #1
Code:
SELECT
t1.unit, t1.dept, t1.code, t1.month, t1.year
FROM
tbl1 t1
WHERE
t1.unit>'500' AND t1.dept>'600'
Query #2
Code:
SELECT DISTINCT
t2.unit, t2.dept, t2.code
FROM
tbl2 t2
WHERE
t2.unit>'500' AND t2.dept>'600'