Help in DELETE script

Hi, I have duplicate records and want to delete any 2nd duplicate row. Please help in DELETE script.
Select * from cmhrec
Sr_no  code    date     charge   Charge2 Code_ID
1        AAA   1-1-2014  24.0      24.0      5
1        AAA   1-1-2014  24.0      24.0      9
2        AAA   1-1-2014  23.0      23.0      4
2        AAA   1-1-2014  23.0      23.0      11
3        AAA   1-1-2014   26.0      28.0     12
3        AAA   1-1-2014   26.0      28.0     19
--Desired output after deleting any 2nd duplicate row.
Sr_no  code    date     charge   Charge2 Code_ID
1        AAA   1-1-2014  24.0      24.0      5
2        AAA   1-1-2014  23.0      23.0      4
3        AAA   1-1-2014   26.0      28.0     12

Thank you
You can simply do this
DELETE t
FROM cmhrec t
WHERE EXISTS
SELECT 1
FROM cmhrec
WHERE SrNo = t.SrNo
AND Code = t.Code
AND Code_ID < t.Code_ID
Please Mark This As Answer if it solved your issue
Please Mark This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page

Similar Messages

  • Need help on deleting after exporting to IDML

    Hi Forum,
    I have a script to export all the "indesign files" found inside the folder... and then remove all the indesign files...
    Instead, Can i have a help to delete....
    the indesign file after exporting to IDML and then
    continue opening the next indesign file, exporting to IDML and deleting it...
    then continue file3....
    The below is the script open indesign files and export to idml and then remove all the files inside the folder Desktop/GENERAL_CS6-IDML/IN_CS6
    var mySourceFolder = Folder("Desktop/GENERAL_CS6-IDML/IN_CS6");
    var myOutFolder = Folder("Desktop/Completed");
    //var Indd_files = get_Files(mySourceFolder,[], ".indd");
    var Indd_files = mySourceFolder.getFiles (/\.indd|\.INDD/i);
    //var Indd_files = get_Files(mySourceFolder,[], ".indd");
    if(Indd_files.length>0)
        for(var w=0;w<Indd_files.length;w++)
            try{
                 app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
                myDoc = app.open(File(Indd_files[w]));
                 app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
                 var myDocNam = stripExt((Indd_files[w].name).replace(/%20/g," "))+"idml";
                 myDoc.exportFile(ExportFormat.INDESIGN_MARKUP, (File(myOutFolder+"/"+myDocNam)));           
    //          myDoc.save(File(myOutFolder+"/"+myDocNam));
                app.activeDocument.close(SaveOptions.no);
            }catch(E){}
    try {
    var copyFolder1 = Folder("Desktop/GENERAL_CS6-IDML/IN_CS6");
    var myFiles2 = copyFolder1.getFiles(/\.indd|\.INDD/i);
    for ( i = myFiles2.length-1; i >= 0 ; i-- ){
    myFiles2[i].remove();
    } catch (e) {}
    Many thanks for the support..

    I hope this is what you expected.
    You can try the following code:
    var mySourceFolder = Folder("Desktop/GENERAL_CS6-IDML/IN_CS6");
    var myOutFolder = Folder("Desktop/Completed");
    //var Indd_files = get_Files(mySourceFolder,[], ".indd");
    var Indd_files = mySourceFolder.getFiles (/\.indd|\.INDD/i);
    //var Indd_files = get_Files(mySourceFolder,[], ".indd");
    if(Indd_files.length>0)
        for(var w=0;w<Indd_files.length;w++)
            try{
                 app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
                 var myFile = File(Indd_files[w]);
                myDoc = app.open(myFile);
                 app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
                 var myDocNam = stripExt((Indd_files[w].name).replace(/%20/g," "))+"idml";
                 myDoc.exportFile(ExportFormat.INDESIGN_MARKUP, (File(myOutFolder+"/"+myDocNam)));          
                app.activeDocument.close(SaveOptions.no);
                myFile.remove();
            }catch(E){}
    Green4ever

  • "Echo" error from deletion script.

    Hey forum!
    I've got this deletion script (attached) that's throw back
    this error:
    Error: Error #2101: The String passed to
    URLVariables.decode() must be a URL-encoded query string containing
    name/value pairs.
    at Error$/throwError()
    at flash.net::URLVariables/decode()
    at flash.net::URLVariables()
    at flash.net::URLLoader/onComplete()
    I don't understand what the problem is. When i look up that
    error i find that usually that error is called by bad echoes, but
    my script doesn't have any. Any help or tips is appreciated!
    Thanks,
    John

    By the way, the script is working as intended.
    Thanks again

  • Can anyone help me deleted this existing photos in my photo library.i already did to sync it up on itunes ang remove all photos ang sync.but still there is 5 photos in my general about eventhough my camera roll is empty.plsss help.thanks.

    can anyone help me deleted this existing photos in my photo library.i already did to sync it up on itunes ang remove all photos ang sync.but still there is 5 photos in my general about eventhough my camera roll is empty.PLEASE HELP!Thanks.

    i mean "and" not "ang" btw.

  • Need help in creating script for "Task Schedule" in Oracle E-Bussiness Suit

    Hi,
    I need some urgent help regarding the scripting of Oracle E-Business Suite application. I am new towards working on Oracle Applications. I have been using LoadRunner 11.0 and protocol oracle applications 11i for the scripting of the application. The problem is as follows:
    Scenario- Schedule an incident to a resource.
    1) Log in to the application.
    2) Open Oracle Forms Page.
    3) Enter the details of the incident number.
    4) Right click on the incident number and then select “schedule” option.
    5) Check / Select the resource listed in the new form.
    6) Click on “schedule” Button.
    7) Exit the oracle forms.
    8) Logout from the application.
    I have recorded the scenario but when I try to run the script, it fails after completing the 4th step from the scenario mentioned above. I have done all the required co-relations..
    Another issue that I have noticed in the scipt is that it records a lot of requests to the AppsTCFServer.
    When I check the Tree View of the script, I have found that there are around 25 requests to the AppsTCFServer recorded in the script. In the header of these requests a TCF Start/Session number gets generated randomly. This number stays the same in few AppsTCFServer request headers and then a new number gets generated and the cycle continues.
    However LoadRunner does not generate this number by itself during replay. I cannot find this number in any previous responses.
    In the last few days, I have tried my hands on Oracle Openscript tool to record the above scenario, but still I am getting the same problem, i.e instead of getting the correct response from the server for the AppsTCFServer requests, I am getting the message "X-session 7098.... not found - aborting ".
    I get this message whether I use LoadRunner tool or the OpenScript tool.
    Please help me solve this issue.
    Thanks & Regards,
    Soumya Mukherjee

    This isn't much of a "code-sharing" site but a "knowledge-sharing" site.  Code posted me may be from a questioner who has a problem / issue / error with his code.   But we don't generally see people writing entire scripts as responses to such questions as yours.  There may be other sites where you can get coding done "for free".
    What you could do is to write some of the code and test it and, if and when it fails / errors, post it for members to make suggestions.
    But the expectation here is for you to write your own code.
    Hemant K Chitale

  • EMail on my iPhone 4s is no longer synching right with my Mac. Things I delete on my Mac are still on my iPhone. HELP!  Deleting in both places is so time consuming. It has worked until recently...not sure what changed!

    Things I delete on my Mac are still on my iPhone. HELP!  Deleting in both places is so time consuming. It has worked until recently...not sure what changed!

    Your email provider may have changed certain settings to do with deleting from server when deleting from client so that it no longer works. Are you using pop or imap? If pop then recreate the account using imap.

  • Can you help me delete photo library & duplicate photo library

    Hi,
    I don't know what I did, but I somehow copied 44 of my daughter's music images into my photo library and then created a duplicate with 43 images.  These 87 images are taking up room and there is no obvious way to delete them. 
    Here's what happens when I touch camera roll it brings me to the photo library -- where 43 out of 44 images are hers:
    I click edit and the only options are share via email, faceboook, twitter, etc. or add to which leads to create a new album.  I don't want to do any of this.  I just want to delete them to make room.
    The same options apply for the Duplicate album as well.
    Can you help me delete the photo library and the duplicate library on my phone?  I only want to keep one video in the camera roll and all of the rest of the images can go.
    Thanks!

    Thanks for your response.  I think you just isolated my issue -- I was trying to upload music and somehow wound up syncing my daughter's photos to my iphone.  I don't know how to delete them because not all of the album/folders are appearing there.  Do you have any suggestions on how to find them?

  • HELP - I deleted an adobe file that I saved to a memory stick and I need it back really badly :(

    HELP - I deleted an adobe file that I saved to a memory stick and I need it back really badly

    Try this Google search:
    http://www.google.cl/#hl=es&tbo=d&sclient=psy-ab&q=free+data+recovery+software+for+flash+d rives&oq=recovery+software+for+flash+drives&gs_l=hp.1.3.0i30j0i5i30l3.9708.24161.0.34539.3 4.26.0.8.8.0.378.7320.2-21j5.26.0...0.0...1c.1.lb0o4diaEEU&pbx=1&bav=on.2,or.r_gc.r_pw.r_q f.&bvm=bv.1355534169,d.eWU&fp=ff7a879957bf69ba&bpcl=40096503&biw=1112&bih=865
    It gave me plenty of hits, but be a little careful. I would suggest using the free trial of one of the paid products. As I have never used one, I cnnot recommand any.
    And remeber: every time you write something on that flash drive, you risk overwriting your lost file, thus decreasing your chances of recovering it.

  • Help! deleted file on dropbox can i recover it on time machine?

    Help I deleted my senior project! So i was responsible and synced my project with drobox and "regularly' backed up my computer. Well, after I turned it in I needed some space in my drobox and deleted my synced folder which deleted it off my computer. I backed up my computer the day after and I guess I didnt realize that I had deleted this IMPORTANT folder for awhile... So its 3 months from when I did that so too late to recover the lost files from dropbox. Is there a way I can recover the folder from time machine? The last backup was way too old before I deleted the file and I only have a backup from the day AFTER I deleted it. Please help!

    Read https://discussions.apple.com/thread/3822378?start=0&tstart=0
    Allan

  • Need help in Java Script

    i Need some help in Java Script,
    am using the following code :
    <script type="text/javascript">
    var newwindow;
    function poptastic(url)
    newwindow=window.open(url,'name','height=300,width=400,left=100, top=100,resizable=yes,scrollbars=yes,toolbar=yes,status=yes');
    if (window.focus) {newwindow.focus()}
    else {newwindow.close()}
    //     if (window.focus) {newwindow.focus()}
    </script>
    In HTML,
    thWorld Environment
    Day, June 5<sup>th</sup>,2005
    Am using onmouseover event, so that when my mouse in on the link, popup is opened....and when my mouse is out of the link, the new window should b closed....
    but according to the above code, the new window is opened but have to close it manually....
    Is there any other way to close the popup when my mouse is out of the link

    Prawn,
    This is not really a good way to make friends. With the cross posting and the posting in a wrong forum anyway thing you have going.
    Please kindly take your question to an appropriate JavaScript forum.
    Have a happy day.
    Cross post from http://forum.java.sun.com/thread.jspa?messageID=3797201

  • Required help in useradd script

    friends i need help in a script i want to creat a script that adds 50 users
    but there is a problem i dont know how to assigne the passwords to the
    users in the script if some body know's about this please give me usefull
    information.
    REGARDS.
    ASIf

    Use Expect. Search google for "expect unix".

  • I'm on my iPod touch 4th generation and I wanna delete apps. Well I hold it down nd the X appears but as soon as I press the X it doesn't do anything for a little bit and then shuts down and turns on again by itself, HELP ME DELETE!

    I'm on my iPod touch 4th generation and I wanna delete apps. Well I hold it down nd the X appears but as soon as I press the X it doesn't do anything for a little bit and then shuts down and turns on again by itself, HELP ME DELETE!

    Try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Reset all settings
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:                                 
    iOS: How to back up           
    - Restore to factory settings/new iOS device.
    If still problem, make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
    Apple Retail Store - Genius Bar    

  • HT1338 Guys I need some help with deleting junk mail/bulk mail...I keep getting this air message that says THE IMAP COMMAND "UID COPY" (TO DELETED MESSAGES) FAILED FOR THE MAILBOX "BULK MAIL" WITH SERVER ERROR: UID COPY SERVER ERROR- PLEASE TRY AGAIN LATE

    I need help in deleting my junk mail/bulk mail...when I dump junk mail and bulk mail into the trash it not allowing me to delete all mail only some. HELP!!

    What program are you using?  And what version?

  • I need help writing a script that finds the first instance of a paragraph style and then changes it

    I need help writing a script that finds the first instance of a paragraph style and then changes it to another paragraph style.  I don't necessarily need someone to write the whole thing, by biggest problem is figuring how to find just the first instance of the paragraph style.  Any help would be greatly appreciated, thanks!

    Hi,
    Do you mean first instance of the paragraph style
    - in a chosen story;
    - on some chosen page in every text frames, looking from its top to the bottom;
    - in a entire document, looking from its beginning to the end, including hidden layers, master pages, footnotes etc...?
    If story...
    You could set app.findTextPreferences.appliedParagraphStyle to your "Style".
    Story.findText() gives an array of matches. 1st array's element is a 1st occurence.
    so:
    Story.findText()[0].appliedParagraphStyle = Style_1;
    //==> this will change a paraStyle of 1st occurence of story to "Style_1".
    If other cases...
    You would need to be more accurate.
    rgds

  • Need help writing a script

    I am trying to convert my prcess from DTS to SSIS. I am running this report out of SAP and then using Monarch to put into the correct form, then I am using the DTS to put it into the database on the SQL server.  I am able to get all the other info to
    move out having so much trouble here to get the plant number. The issuse is that it is on top on the page and it will change when a new plant is needed.
    Thanks for any help
    I need help wrting a script that will put that 7010 into a cloumn nnamed plant number.

    To convert from DTS packages to SSIS you can just open the DTS package in a new SSIS project (depends on target SSIS version by using SSDT or BIDS).
    The rest is mechanics how the iteration with SAP is done and may be beyond the scope of this forum.
    Arthur
    MyBlog
    Twitter

Maybe you are looking for

  • BI : ABAP Rule in transformation

    Hi Experts , I have problem in the ABAP rule. there is an 3x update rule which contains the routine. In the transformation when i create and check the routine  , I am getting the below error : "E:The field "SOURCE_FIELDS-PEINH" cannot be changed. -".

  • How do I open a multi-tab excel document in numbers?

    New mac for Christmas! I am reluctant to instal MS Office and am willing to try out Apples programs. Only major issue is I cannot open my multi-tab workbooks that I created in Excel. I use them daily. Is there anyway to open them? Does the Numbers pr

  • EA4500 - not as easy to set up

    Unfortunately the Linksys EA4500 is not as easy to "Set Up & Manage with Ease" as they claim. After trying to connect my Dell color laser network printer, which was working just fine with the replaced Dlink DIR-655 router, it turns out that the suppl

  • Please explain 3G-s Pre-Order for Store Pickup procedure

    I've done this but what exactly does this get me? The fine print says +'Pre-authorization does not guarantee iPhone availability at an Apple Retail Store. iPhone is sold on a first-come, first-served basis'.+ So what exactly is the benefit to going t

  • Feature to spit out a list of users that need a password reset from DB?

    Not too sure which category this would be in, so please direct me if you know As the title says, is there a feature or tool that exports a list of usernames that have their password expiring in, for example, the next 10-20 days? It's a common occurre