Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 147
  • Last Modified:

Distinct values from using Substring

Hello,

Can someone help me get distinct values? I attached sample data, expected results and then the rules for each column.

Thank you
DIM-OWNER-11-24-14-2.xls
0
angel7170
Asked:
angel7170
1 Solution
 
sdstuberCommented:
SELECT owner_nm,
         MAX(addr_1) addr_1,
         MAX(addr_2) addr_2,
         py_city,
         py_zip_cd
    FROM (SELECT py_nam_1 || py_nam_2 || py_nam_3 owner_nm,
                 CASE WHEN vt_text_type LIKE 'AI%' THEN py_addr_1 || vt_text END addr_1,
                 CASE WHEN vt_text_type LIKE 'AS%' THEN py_addr_2 || vt_text END addr_2,
                 py_city,
                 py_zip_cd
            FROM yourtable)
GROUP BY owner_nm, py_city, py_zip_cd
0
 
angel7170Author Commented:
thank you very much. It worked as expected
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now