Re: Duplicate Rows
Date: Sat, 26 Jul 2008 10:24:04 +0100
<artmerar_at_yahoo.com> wrote in message
> I figured I'd ask this too. I know how to remove duplicate rows from
> a table, but this example used an analytical function. I'm new to
> these and do not get a huge chance to use them, so I'm always
> forgetting how they work.
> Please see this:
> select * from customer
> where rowid in
> (select rowid from
> (partition by customer_id order by customer_id ) dup
> from customer)
> where dup > 1);
> Ok, that did show me the duplicates, but what if a duplicate was made
> up of more than 1 column? Can I still use an analytical function?
> This is where I might learn about these things......
> Thank you.
The OVER clause accepts a list of columns:
SELECT * FROM
(SELECT customer_id, col2, col3,
(PARTITION BY customer_id, col2, col3 ORDER BY customer_id, col2, col3 ) dupFROM customer) t
WHERE dup > 1;
-- David PortasReceived on Sat Jul 26 2008 - 04:24:04 CDT