Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: SQL puzzle...

Re: SQL puzzle...

From: David Portas <REMOVE_BEFORE_REPLYING_dportas_at_acm.org>
Date: Wed, 9 Jun 2004 12:29:05 +0100
Message-ID: <IvudneqOd_YwaVvdRVn-vw@giganews.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US