Heres the example for your query
C:\>db2 "create table data (col1 int,col2 char(5))"
DB20000I The SQL command completed successfully.
C:\>db2 "insert into data values (1,'hai'),(2,'how'),(3,'him')"
DB20000I The SQL command completed successfully.
C:\>db2 "insert into data values (1,'hai'),(2,'how'),(3,'him')"
DB20000I The SQL command completed successfully.
C:\>db2 "insert into data values (1,'hai'),(2,'how'),(3,'him')"
DB20000I The SQL command completed successfully.
C:\>db2 "insert into data values (1,'hai'),(2,'how'),(3,'him')"
DB20000I The SQL command completed successfully.
C:\>db2 "insert into data values (1,'hai'),(2,'how'),(3,'him')"
DB20000I The SQL command completed successfully.
C:\>db2 "select * from data"
COL1 COL2
----------- -----
1 hai
2 how
3 him
1 hai
2 how
3 him
1 hai
2 how
3 him
1 hai
2 how
3 him
1 hai
2 how
3 him
15 record(s) selected.
C:\>db2 "delete from (select row_number() over ( partition by col1 order by col2 desc ) as rn from
data ) where rn>1"
DB20000I The SQL command completed successfully.
C:\>db2 "select * from data"
COL1 COL2
----------- -----
1 hai
2 how
3 him
3 record(s) selected.
Thanks & Regards,
Gokul.Sagi
Miracle Software Systems pvt.ltd
Web:www.miraclesoft.com
contactno:+91-9290063929
email:gs...@miraclesoft.com
------- Original Message -------
From : malla kishore[mailto:mallak...@gmail.com]
Sent : 8/28/2007 7:23:19 AM
To : mirac...@googlegroups.com
Cc :
Subject : RE: Re: How to delete duplicate rows in the table
Hi Gokul,
Nice to have u r reply..
Can you please breif that with example
Advance Thanks
On 8/28/07, Gokul Sagi <gs...@miraclesoft.com> wrote:
>
>
>
> Hi
>
> This command is helpful for deleting the duplicate rows in the given
> example and it worked
> succesfully.
>
> db2 " delete from (select row_number() over (partition by col1 order by
> col2 desc ) as rn from data
> data ) where rn >1 "
>
>
>
> Thanks & Regards,
>
> Gokul.Sagi
> Miracle Software Systems pvt.ltd
> Web:www.miraclesoft.com
> contactno:+91-9290063929
> email:gs...@miraclesoft.com
>
>
> ------- Original Message -------
> From : malla kishore[ mailto:mallak...@gmail.com]
> Sent : 8/28/2007 6:07:06 AM
> To : mirac...@googlegroups.com
> Cc :
> Subject : RE: How to delete duplicate rows in the table
>
> Hi Team,
>
> Can any one suggest the way's to delete the duplicate rows in a table
>
> example
> i have
>
> Table data
>
> col1 col1
>
> 1 hai
> 2 how
> 1 hai
>
> i want
>
>
> col1 col1
>
>
> 1 hai
> 2 how
>
>
>
> waiting for your replies
> Thanks
> kishore
>
>
>
>
>
> >
>
--
కిశోర్ మల్ల
IBM Certified Database Associate,
IBM Information Management (DB2 UDB),
Miracle Software Systems Inc.
email: smull...@miraclesoft.com
Mobile: +919923020321