How to select 1 row for a person that has 2 accounts in the system

  • **1st part to achieve:** I'm trying to return the row for a person "ABC1" where it has the APP_START_DT.
    or APP_SUBMIT_DT but I want to return the Acct_CR_DT as well which in this case is 9/5/2018 and I don't want duplicates. One row per person for records like these.

    **2 part I want to achieve:** When they have any date, return the latest status based on that, which is this case it should look at the "APP_SUBMIT_DT" and return "App submitted" if there are further dates for that record, should look at those dates and return 1 row with latest status.

    Attached is the sample file for reference.

  • It's handy that you attached sample data, however...
    1.) it's a spreadsheet.  Folks, on average, are not that interested in taking the "unnecessary risk" of downloading a spreadsheet from the internet.
    2.)  It's not entirely clear exactly what you want in the way of output, as while you have sample data, you have not supplied the expected results based on the sample data.
    3.) You really should learn to use IF Code blocks, and use CREATE TABLE and INSERT statements in text format to allow people to just plain old copy/paste to run your insert script and thus be able to test their solutions.

    If you can't or won't do those simple things, you may not get much help....

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

  • Look at ROW_NUMBER(). If you follow Steve's advice, you may get tested code.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 3 posts - 1 through 3 (of 3 total)

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