Out of 3 same/ similar rows, remove two and keep one

  • Jonathan I may need to check again, but I think it works. Thank you!! I really appreciate your help.

  • @Phil Parkin,  simply a query which removes them from the rows that are selected.

    I don't have any CREATE statements. I am just selecting rows from CTE.

    You have >600 points, so I assume that you've been asked to do this before? Not providing consumable DDL and sample data has, in this case, resulted in a longish thread which would otherwise have been resolved far sooner. Surely you can see that?

    Just to be clear, so that you don't use the same excuse in future, you can easily make up CREATE and INSERT statements based on your posted image.

    DROP TABLE IF EXISTS #final_output;

    CREATE TABLE #final_output(FreightBillId INT, VoucherNum VARCHAR(20), blah blah)

    INSERT #final_output
    (
    FreightBillId
    ,VoucherNum
    , ...
    )
    VALUES
    ()

    Had you done this and posted your desired output, this thread would have been closed far sooner.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • You have multiple problems with your approach:

    First, you NEVER delete General Ledger entries! You can offset them to change the total but NEVER delete them. That being said who in your accounting department told you that you can ? They should be dismissed immediately.

    Second, if you're doing this for a report then Select the data you want into a temporary table and then manipulate that table by deleting the rows that you don't want to see and return what's left of the table from your stored proc.

    Just the ramblings of an old man.

     

  • This was removed by the editor as SPAM

  • This was removed by the editor as SPAM

Viewing 5 posts - 16 through 19 (of 19 total)

You must be logged in to reply to this topic. Login to reply