Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: SQL puzzle...
You haven't stated your rule for removing redundant rows. Assuming you want
one arbitrary row of each (start,end) pair where Value is equal and assuming
(start,end) is the primary key:
SELECT A.start, A.end, A.value
FROM Graphe AS A
LEFT JOIN Graphe AS B
ON A.start = B.end
AND A.end = B.start AND A.value = B.value AND A.start > B.start WHERE B.start IS NULL ;
This is SQL92 (apart from the use of the non-delimited reserved word "END" as a column name) but was tested on SQLServer 2000. Possibly you'll need to amend it depending on your Oracle version.
Hope this helps.
-- David Portas SQL Server MVP --Received on Wed Jun 09 2004 - 06:29:05 CDT