Deleting consecutive duplicates

hi,
i have the below requirements:
1)my table consisits of below records:
id, code
1,A
1,A
2,B
1,A
i want to remove consecutive duplictaes and my o/p should be
1,A
2,B
1,A
2)second requirement is
id,code
1,A
2,A
3,B
4,A
i want to remove the duplicate based on code field alone/
My o/p should be
id,code
1,A
3,B
4,A
Please help me to achieve this.
Any ideas will be helpful
Thanks,
Pandeeswaran

>
1)my table consisits of below records:
id, code
1,A
1,A
2,B
1,A
i want to remove consecutive duplictaes and my o/p should be
1,A
2,B
1,A
Not possible. There is no row order in relational tables. Only ORDER BY guarantees row order.
2)second requirement is
id,code
1,A
2,A
3,B
4,A
i want to remove the duplicate based on code field alone/
My o/p should be
id,code
1,A
3,B
4,A
Here it is possible since ORDER BY id will produce right order:
SQL> select * from tbl
  2  order by id
  3  /
        ID C
         1 A
         2 A
         3 B
         4 A
SQL> delete tbl
  2    where rowid in (
  3                    select  rowid
  4                      from  (
  5                             select  rowid,
  6                                     case lag(code) over(order by id)
  7                                       when code then 0
  8                                       else 1
  9                                     end start_of_group
10                               from  tbl
11                            )
12                      where start_of_group = 0
13                   )
14  /
1 row deleted.
SQL> select * from tbl
  2  order by id
  3  /
        ID C
         1 A
         3 B
         4 A
SQL> SY.

Similar Messages

  • HT4915 When i did my itunes match, there were some duplicated albums and songs.  I have gone into my library and deleted the duplicates, but they still show up on my iphone as duplicates.  What can i do to get rid of them?

    When I did my itunes match, there were some duplicated albums and songs in my library.  I have gone back into my library from my computer, and deleted the duplicates.  When I did so, itunes did not ask me if I wanted to delete them from the cloud.  They are still showing up on my iphone as duplicates in the cloud.  What can I do to get them from showing up in my iphone?

    They are not on the iphone in the first place.  It is just a setting that allows you to see the songs that are available in icloud, but not on your iphone.  If you turn the setting to off, then you no longer see the songs that are in icloud, but NOT on your iphone.

  • How to delete the duplicate email address in BP master data

    Hi,
    When  you get an email ids from the third party vendor and you are loading into CRM BP master data.  how to delete the duplicate email address already exits in the system.  In CRM you can create the same BP with different id.   I would like to know how to delete the email address during importing email addresses from the third party tool.
    During the campaign you are sending email to all your customers, when the customer want to unsubscibe the email address from your list, how to unsubcribe the email address and how to updat the BP master data. 
    If you are sending the email to customer, you are using html or simple text, if the customer wants only html or simple text, how you to specify in the system?
    thanks,
    arul

    Hello Arul,
    welcome to the SDN CRM Development forum.
    1. I think you should clear the data with duplicate E-Mail adresses in the external tool.
    2. Unsubscription could be done by a Marketing Attribute which could be set by using a Target Group which is created by Campaign Automation. Have a look at this Toppic. There is also a Best Practice avaliable at http://help.sap.com/bp_crmv340/CRM_DE/index.htm.
    3. Also HTML or Simple text can be mained in a Marketing Attribute. You have to use different Mail Forms to which are sent to different Target groups.
    Regards
    Gregor

  • I just upgraded to the latest version of iTunes and it duplicated virtually every track in my music library. I need a quick way to delete the duplicates. Sorting by "Date Added" will not help because they are all listed as added on 12/12/2011.

    Library Duplicated
    I just updated to the latest version of iTunes and it duplicated virtually every track in my library. I need a quick way to delete the duplicates. Sorting by "Date Added" will not work, because every track is listed as added on 12/12/2011 even though this happened today 12/19/2011.

    I've written a script called DeDuper which can help remove unwanted duplicates. See this  thread for background.
    tt2

  • How do I delete multiple duplicates of songs in my playlist without doing one at a time.  Windows 7 on HP.  Lexmac

    How do I delete multiple duplicate songs from my playlist without doing one at a time?
    <Edited by Host>

    I've written a script called DeDuper which can help remove unwanted duplicates. See this  thread for background.
    tt2

  • How to delete the duplicate records in a table without promary key

    I have a table that contains around 1 million records and there is no promary key or auto number coulums. I need to delete the duplicate records from this table. what is the simple effective way to do this.

    Please see this link:
    Remove duplicate records ...
    sqldevelop.wordpress.com

  • How to delete the duplicate data  from PSA Table

    Dear All,
    How to delete the duplicate data  from PSA Table, I have the purchase cube and I am getting the data from Item data source.
    In PSA table, I found the some cancellation records for that particular records quantity  would be negative for the same record value would be positive.
    Due to this reason the quantity is updated to target but the values would summarized and got  the summarized value  of all normal and cancellation .
    Please let me know the solution how to delete the data while updating to the target.
    Thanks
    Regards,
    Sai

    Hi,
    in deleting the records in PSA table difficult and how many you will the delete.
    you can achieve the different ways.
    1. creating the DSO maintain the some key fields it will overwrite the based on key fields.
    2. you can write the ABAP logic deleting the duplicate records at info package level check with the your ABAPer.
    3.you can restrict the cancellation records at query level.
    Thanks,
    Phani.

  • Abap Code to Delete the Duplicate Entries in Datasource

    hI Friends I have a code that I am writing to delete the duplicate entries from CRM Custom Datasource  but it is throwing me error that INVERNO The specified type has no structure and therefore no component called INVERNO Should i define the structure please correct my code below so that it will work to delete the duplicate entries          
    Please help
    Data: l_s_ZOXD530051 like ZOXD530051. ***Extract Structure of Data source
    Case i_DATASOURCE.
    when 'ZZ_DS_CUSTOM_CRM_VALUES'.
    Sort C_T_DATA by INVERNO ZMKT_TYP.
    *write this Statement.
    DELETE ADJACENT DUPLICATES FROM C_T_DATA COMPARING INVERNO ZMKT_TYP.
    endcase.
    Thanks
    Soniya
    null

    Hi
    It means there's no field called INVERNO:
    Data: l_s_ZOXD530051 like ZOXD530051. ***Extract Structure of Data source
    Case i_DATASOURCE.
    when 'ZZ_DS_CUSTOM_CRM_VALUES'.
    <b>*Sort C_T_DATA by INVERNO ZMKT_TYP. <------</b>
    Sort C_T_DATA by INTRENO ZINS_TYP.
    *write this Statement.
    DELETE ADJACENT DUPLICATES FROM C_T_DATA COMPARING INTRENO ZINS_TYP.
    endcase.
    Max

  • How to delete the duplicate requests in a cube after compression.

    Hi experts,
        1. How to delete the duplicate requests in a cube after compression.?
        2. How to show a charaterstics and a keyfigure side by side in a bex query output?
    Regards,
    Nishuv.

    Hi,
    You cannot delete the request as its compressed as all the data would have been moved to E table ..
    If you have the double records you may use the selective deletion .
    Check this thread ..
    How to delete duplicate data from compressed requests?
    Regards,
    shikha

  • How to delete the duplicate cards in ALUI

    Hi,
    How to delete the duplicate cards in knowledge directory
    Thanks & Regards
    Dheeraj
    Edited by: dheeraj on Sep 17, 2008 2:31 PM

    Not sure if there is an automated way to do this, but I get around it by just searching on (2), (3), (4).
    Not practical for large installs, but it works in our small environment.
    You might be able to use the Smart Sort utility to find files that have () characters in them? Not positive though.
    It would make a great enhancement request to add dupes to either a log file or better yet an admin utility to track the living documents to ensure they are fixed!
    (I'm going to file such an enhancement right now!)

  • How to delete the duplicate cards in alui crawlers

    How to delete the duplicate cards in alui crawlers

    Not sure if there is an automated way to do this, but I get around it by just searching on (2), (3), (4).
    Not practical for large installs, but it works in our small environment.
    You might be able to use the Smart Sort utility to find files that have () characters in them? Not positive though.
    It would make a great enhancement request to add dupes to either a log file or better yet an admin utility to track the living documents to ensure they are fixed!
    (I'm going to file such an enhancement right now!)

  • HT2905 Is there a way to automatically delete exact duplicates in iTunes 11

    Has anyone found a way to automatically delete Exact Duplicates from iTunes 11.  As I read the instructions, it can only be done by comparing the songs with the same title, making sure that it is the same album, etc.  Then I have been going through the duplicates and pressing CTRL in Windows to select the next duplicate song to delete.  I have a very large library and this is going to take hours.
    I guess I didn't get the instructions correctly when I backed up my Library to move from an old laptop to a new one.  I am going to have to go back and read those again because this brand new HP is having problems like the past few that I have received from HP.  I will never recommend an HP Product, I can tell you that.
    Thanks to all for reading this and I hope someone has an answer to automate it.

    When deduping use Shift > View > Show Exact Duplicate Items as this is normally a more useful selection. You need to manually select all but one of each group to remove. Sorting the list by Date Added may make it easier to select the appropriate tracks. If you have multiple entries in iTunes connected to the same file on the hard drive then don't send to the recycle bin. Use my DeDuper script if you're not sure, don't want to do it by hand, or want to preserve ratings, play counts and playlist membership. See this thread for background and please take note of the warning to backup your library before deduping.
    (If you don't see the menu bar press ALT to show it temporarily or CTRL+B to keep it displayed)
    See also HT2905: How to find and remove duplicate items in your iTunes library.
    (Duplicate link)
    If you still have the original library on the old laptop see this  migrate iTunes library post. It may be easier and/or better to redo the transfer...
    tt2

  • How to delete multiple duplicates of multiple songs?

    How to delete multiple duplicates of multiple songs from my library at the same time, rather than each individually?

    Apple's official advice on duplicates is here... HT2905: How to find and remove duplicate items in your iTunes library. It is a manual process and the article fails to explain some of the potential pitfalls such as lost ratings and playlist membership.
    Use Shift > View > Show Exact Duplicate Items to display duplicates as this is normally a more useful selection. You need to manually select all but one of each group to remove. Sorting the list by Date Added may make it easier to select the appropriate tracks, however this works best when performed immediately after the dupes have been created.  If you have multiple entries in iTunes connected to the same file on the hard drive then don't send to the recycle bin.
    Use my DeDuper script if you're not sure, don't want to do it by hand, or want to preserve ratings, play counts and playlist membership. See thisthread for background, this post for detailed instructions, and please take note of the warning
    to backup your library before deduping.
    (If you don't see the menu bar press ALT to show it temporarily or CTRL+B to keep it displayed.)
    The most recent version of the script can tidy dead links as long as there is at least one live duplicate to merge stats and playlist membership to and should cope sensibly when the same file has been added via multiple paths.
    tt2

  • I want to delete my duplicate songs, but I have thousands of songs and cannot realistically go through and review and delete them one at a time.  Can I do it all at once?

    I want to delete my duplicate songs, but I have thousands of songs and cannot realistically go through and review and delete them one at a time.  Can I do it all at once?

    Apple's official advice is here... HT2905 - How to find and remove duplicate items in your iTunes library. It is a manual process and the article fails to explain some of the potential pitfalls.
    Use Shift > View > Show Exact Duplicate Items to display duplicates as this is normally a more useful selection. You need to manually select all but one of each group to remove. Sorting the list by Date Added may make it easier to select the appropriate tracks, however this works best when performed immediately after the dupes have been created.  If you have multiple entries in iTunes connected to the same file on the hard drive then don't send to the recycle bin.
    Use my DeDuper script if you're not sure, don't want to do it by hand, or want to preserve ratings, play counts and playlist membership. See this thread for background and please take note of the warning to backup your library before deduping.
    (If you don't see the menu bar press ALT to show it temporarily or CTRL+B to keep it displayed)
    tt2

  • How do i get rid of duplicates in my photo library?  I imported the photos again by mistake and dont want to do it manually.  is there a way to have iphoto compare and delete all duplicates?

    How do i delete duplicate photos in my iphoto library.  i imported them (1500 pics) twice and don't want to manually go through them all.  Is there a way to get iphoto to compare photos and delete the duplicates?

    There are two apps, actually one app and one Applescript script, for finding and removing duplicate photos from iPhoto. They are:
    Duplicate Annihilator
    iPhoto AppleScript to Remove Duplicates
    OT

Maybe you are looking for

  • Cannot connect to iTunes store connection with the server has been reset

    I have updated itunes and now I cannot connect to the itune store says connection is reset but all other programs and internet is working properly. Please help

  • Can any one give guidence

    hi, experts     i am seraching job on abap     here is my objects   u2022     Developed a Stock overview report. u2022     Developed a Sales order report. u2022     Developed Vendor analysis report. u2022     Developed a report on Account receivable

  • Problem in reading data using scanner

    In a client - server application,Iam sending the data "~!Raam7krishna~!" continously to the server periodically.... In the server side,Iam using scanner to read the data with the delimiter ~!. Server should continously read the data from the client.s

  • Chinese characters displayed as ##### in Web Intelligence

    Hello, I am using Business Object XI 3.1 and created a Web Intelligence report however it is not able to display the chinese character name for some Taiwan vendors. On my backend BW 7.0, I can see the chinese characters. What could be the cause? Any

  • What is the best way to migrate settings/apps/files from late 2008 MBP to new 2012 MBA?

    I have the 2008 MBP backed up via TM to an external HD that is FW800, but is USB 2.0 capable.  I was hoping the TB/FW adapter would come out from Apple soon, and maybe it will.  Bottom line, my new MBA arrives next week, and I'm not sure when the TB/