How to select from 5 lines but only display 3

  • So I am not sure if someone is able to help assist me or not but I am in need of a little assistance. I currently have an address database that has a name column, 5 separate columns for address lines, and a separate column for city, state, zip and country. I need the following to happen if possible only because we can only display name line and only 3 address lines and then a combination line for city,st, zip country which makes 5 lines total

    After Name and Address Line1, Address Line 2 - 5 must do the following:
    - Check if blank
         - if so, roll up next address line(s)
    - Check to see if any combination of city, state, zip or city, state, zip and country are in address lines 2-5
         - if so, mark as blank and roll up if not blank line(s) after
    - Check to see if any lines start with '3PB='
         - if so, mark as blank and roll up if not blank line(s) after
    - If everything above is check and still more than 3 lines, roll up # of lines after onto Address Line 3

  • Post some DDL and sample data.  Your question looks fairly involved and I don't want to waste my time writing a query against data that doesn't accurately represent your problem.

    Wes
    (A solid design is always preferable to a creative workaround)

  • whenriksen - Thursday, January 12, 2017 12:12 PM

    Post some DDL and sample data.  Your question looks fairly involved and I don't want to waste my time writing a query against data that doesn't accurately represent your problem.

    The attachment in my original post is sample data. I am trying to right code however not having much success so far. Reason why I reached out.

  • jonathanm 4432 - Thursday, January 12, 2017 12:15 PM

    whenriksen - Thursday, January 12, 2017 12:12 PM

    Post some DDL and sample data.  Your question looks fairly involved and I don't want to waste my time writing a query against data that doesn't accurately represent your problem.

    The attachment in my original post is sample data. I am trying to right code however not having much success so far. Reason why I reached out.

    You also need to include your table definition and what you want the results to look like.  You will get more help if you put your data into a script rather than an excel file.

    Wes
    (A solid design is always preferable to a creative workaround)

  • jonathanm 4432 - Thursday, January 12, 2017 12:15 PM

    whenriksen - Thursday, January 12, 2017 12:12 PM

    Post some DDL and sample data.  Your question looks fairly involved and I don't want to waste my time writing a query against data that doesn't accurately represent your problem.

    The attachment in my original post is sample data. I am trying to right code however not having much success so far. Reason why I reached out.

    Attachments can contain malware, so people are hesitant to open them.  Attachments are also not readily consumable, which makes it less likely that people will answer your question.  Check the first link in my signature for the preferred way to post sample data.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 5 posts - 1 through 4 (of 4 total)

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