0

Hi I have a query in Oracle and im not sure if i can do what im looking to do.

I have a query something like below

select tableA.Value, tableB.Value, tableC.Value, tableD.Value

from tableA

join tableB
on ######

join tableC
on #####

join tableD 
on #####

I need to limit this result set to only records that have a unique tableA.Value

Can I do a multiple row select and join on multiple tables then some how add something like

GROUP BY tableA.Value

HAVING Count(tableA.Value) = 1)

to the end to limit the rows selected to those with a unique value in one of those rows

#########################EDIT

Some data to maybe explain better

1234 ABC TEST

2345 BCD TEST

2345 GGG TEST

3456 CDE TEST

4567 DEF TEST

4567 FFF TEST

5678 EFG TEST

desired result set;

1234 ABC TEST

3456 CDE TEST

5678 EFG TEST

I want to limit records to ones that have a unique column 1

4

1 回答 1

4
select tableA.Value, tableB.Value, tableC.Value, tableD.Value
  from tableA 
join tableB on ######
join tableC on #####
join tableD on #####
where 1 = (select count(*) from tableA tableA2 where tableA2.value = tableA.value)

I didn't work in Oracle for years, so I'm not sure the syntax is correct, but the idea is to rename tableA from the subquery to tableA2 to not have ambiguity when comparing tableA.value to tableA2.value.

于 2012-10-05T16:08:17.477 回答