Solved

Distinct values from using Substring

Posted on 2014-11-24
2
141 Views
Last Modified: 2014-11-25
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
Comment
Question by:angel7170
2 Comments
 
LVL 73

Accepted Solution

by:
sdstuber earned 500 total points
ID: 40463062
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
 

Author Closing Comment

by:angel7170
ID: 40464484
thank you very much. It worked as expected
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question