SoonerTJ
June 20th, 2005, 12:57 PM
Hi.
I have a problem, hoping to get any ideas/help I can. Let
me know what you think. Thanks.
My problem is identifing non duplicate data, not based on a
specific row, but based on specific "sets" of rows (in this
case tbl_id being the same number constitutes a set). Tbl =
1 or 2 or 3, etc.
Here's some test data from tmp_qual table.
tbl id qual_tbl qual_value_type qual_value inc_excl
1 1 16 916-454 +
1 1 16 916-636 +
1 1 16 916-989 +
2 2 16 916-989 +
3 3 16 916-454 -
4 4 16 913-315 -
4 4 16 916-454 -
4 4 16 916-989 -
5 5 16 916-454 -
5 5 16 916-636 -
5 5 16 916-989 -
5 5 16 972-408 -
From this data I would like tbl_id = 5 to be returned:
tbl id qual_tbl qual_value_type qual_value inc_excl
5 5 16 916-454 -
5 5 16 916-636 -
5 5 16 916-989 -
5 5 16 972-408 -
I need this "Set" of data to be identified as the only non
duplicate set from the original data. Because the 972-408
value differentiates it from tbl_id #1.
I used this query:
SELECT tbl_id, qual_tbl, qual_value_type, qual_value,inc_excl
FROM #qual_tbl
WHERE tbl_id NOT IN ( SELECT tbl_id, qual_value
FROM #qual_tbl q1
WHERE ( SELECT count( * )
FROM #qual_tbl q2
WHERE q2.qual_value = q1.qual_value
AND q2.tbl_id != q2.tbl_id) = 0
)
And nothing returned, although I expected it too.
Any ideas/help??
Please let me know. Thanks!
I have a problem, hoping to get any ideas/help I can. Let
me know what you think. Thanks.
My problem is identifing non duplicate data, not based on a
specific row, but based on specific "sets" of rows (in this
case tbl_id being the same number constitutes a set). Tbl =
1 or 2 or 3, etc.
Here's some test data from tmp_qual table.
tbl id qual_tbl qual_value_type qual_value inc_excl
1 1 16 916-454 +
1 1 16 916-636 +
1 1 16 916-989 +
2 2 16 916-989 +
3 3 16 916-454 -
4 4 16 913-315 -
4 4 16 916-454 -
4 4 16 916-989 -
5 5 16 916-454 -
5 5 16 916-636 -
5 5 16 916-989 -
5 5 16 972-408 -
From this data I would like tbl_id = 5 to be returned:
tbl id qual_tbl qual_value_type qual_value inc_excl
5 5 16 916-454 -
5 5 16 916-636 -
5 5 16 916-989 -
5 5 16 972-408 -
I need this "Set" of data to be identified as the only non
duplicate set from the original data. Because the 972-408
value differentiates it from tbl_id #1.
I used this query:
SELECT tbl_id, qual_tbl, qual_value_type, qual_value,inc_excl
FROM #qual_tbl
WHERE tbl_id NOT IN ( SELECT tbl_id, qual_value
FROM #qual_tbl q1
WHERE ( SELECT count( * )
FROM #qual_tbl q2
WHERE q2.qual_value = q1.qual_value
AND q2.tbl_id != q2.tbl_id) = 0
)
And nothing returned, although I expected it too.
Any ideas/help??
Please let me know. Thanks!