No you can't do this as a select distinct statement. As with all other sql statements they work on rows of data...It is a common mistake...The easiest way to do this is have a select distinct of the fields you wish i.e. this will get the distinct rows of data you wish...For the other fields you will have do a select within the outer select distinct loop because there could be more than one row retrieved which is why you are confused e.g.
select distinct field1, field2, field3
from table1
begin
select field3, field4
from table2
/* select the fields based on a key from the outer loop */
where field5 = :field1
and field6 = :field2
begin
<statements>
end
end
the above is only a guide but you may have to do a cursor select for the outer select as some languages are fussy that you can't have nested select loops...i.e. you have to do a cursor select as the outer loop
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.