Xref: alice comp.databases.oracle.server:73817
Path: alice!news-feed.fnsi.net!hammer.uoregon.edu!logbridge.uoregon.edu!nntp2.deja.com!nnrp1.deja.com!not-for-mail
From: "   " <mackdm@my-Deja.com>
Newsgroups: comp.databases.oracle.server
Subject: Re: Skill testing SQL question
Date: Fri, 12 Nov 1999 15:21:36 -0800
Organization: Deja.com - Before you buy
Lines: 110
Message-ID: <BHBKNJPMMNODAAAA@my-deja.com>
Mime-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
To: "comp.databases.oracle.server@list.deja.com" <comp.databases.oracle.server@list.deja.com>
X-Sent-Mail: off
X-Mailer: MailCity Service
X-Sender-Ip: 202.58.254.108
Content-Language: en
Content-Length: 2690
X-DejaID: _xiz/AIPid6zWCD6BWIVyPFQSoXU8yZZZ?=

 There is a very easy solution to this question.
And a very reasonably one by the interviewer.

Solution

delete DUPE_TABLE a
  where rowid = (select max(rowid)
                    from DUPE_TABLE b
                    where b.aa = a.aa
                      and b.bb = b.bb)
--

On Fri, 5 Nov 1999 08:54:50    Jonathan Lewis wrote:
> Message from the Deja.com forum: 
> comp.databases.oracle.server
> Your subscription is set to individual email delivery
>>
>
>It's not a good question, it's either a
>very bad question or a totally inspired
>question.
>
>
>With 6 rows and two columns as set,
>the sensible solution is:
>
>
>select * from dupe_table;
>
>--  examine output by eye
>
>delete from dupe_table where aa = 1 and rownum = 1;
>delete from dupe_table where aa = 2 and rownum = 1;
>delete from dupe_table where aa = 3 and rownum = 1;
>
>select * from dupe_table;  -- to check results
>
>commit;
>
>
>If the intent of your interviewer was to
>discover how smart you were at writing
>'clever' SQL, the question was bad.
>
>If the interviewer was trying to find out
>whether you were able to spot pragmatic
>realistic, simple solutions before diving
>for 'esoteric technology' then the question
>was brilliant.
>
>
>--
>
>Jonathan Lewis
>Yet another Oracle-related web site:  http://www.jlcomp.demon.co.uk
>
>argosy22@my-deja.com wrote in message <7vss7n$c36$1@nnrp1.deja.com>...
>>Hello all,
>>
>>This is a good skill testing question
>>that I was asked in an interview.
>>
>>You have a table, DUPE_TABLE,
>>with two fields, AA, and BB.
>>No primary key.  Dupe data.
>>Only 6 rows.
>>2 sets of the same exact 3 rows.
>>
>>DUPE_TABLE:
>>AA BB
>>1 x
>>2 y
>>3 z
>>1 x
>>2 y
>>3 z
>>
>>
>>You want to delete 3 rows, so that
>>you have only one set of 3:
>>
>>AA BB
>>1 x
>>2 y
>>3 z
>>
>>
>
>
>
>
>
>
> _____________________________________________________________
> Deja.com: Before you buy.
> http://www.deja.com/
> * To modify or remove your subscription, go to
> http://www.deja.com/edit_sub.xp?group=comp.databases.oracle.server
> * Read this thread at
> http://www.deja.com/thread/%3C941792675.26450.0.nnrp-09.9e984b29%40news.demon.co.uk%3E
>
>


--== Sent via Deja.com http://www.deja.com/ ==--
Share what you know. Learn what you don't.


 Sent via Deja.com http://www.deja.com/
 Before you buy.
