Would like to find out how I can show one row per person if the mailing address and the permanent address are the same, if they are different then show both.
[tt]
ID Name Addr Zip AdrType
123 Joe 34 Main St 92191 MA
123 Joe 34 Main St 92191 PR
234 Gil 65 West St 92192 MA
234 Gil 91 East Rd 94596 PR
598 May 83 First Ave 94596 PR
[/tt]
Output I typed a BO in the display below to indicate
that the address is the same for BOth. Not sure if
doing that is possible too?
[tt]
ID Name Addr Zip AdrType
123 Joe 34 Main St 92191 [red]BO[/red]
234 Gil 65 West St 92192 MA
234 Gil 91 East Rd 94596 PR
598 May 83 First Ave 94596 PR
[/tt]
Here is the SQL that someone had set up as part of a view, I extracted the releveant portion, since the actual view was designed to pick one record per person regardless.
[tt]
ID Name Addr Zip AdrType
123 Joe 34 Main St 92191 MA
123 Joe 34 Main St 92191 PR
234 Gil 65 West St 92192 MA
234 Gil 91 East Rd 94596 PR
598 May 83 First Ave 94596 PR
[/tt]
Output I typed a BO in the display below to indicate
that the address is the same for BOth. Not sure if
doing that is possible too?
[tt]
ID Name Addr Zip AdrType
123 Joe 34 Main St 92191 [red]BO[/red]
234 Gil 65 West St 92192 MA
234 Gil 91 East Rd 94596 PR
598 May 83 First Ave 94596 PR
[/tt]
Here is the SQL that someone had set up as part of a view, I extracted the releveant portion, since the actual view was designed to pick one record per person regardless.
Code:
SELECT entity_uid pidm,
address_type typ,
address_seq_no seqno,
street_line1 street1,
street_line2 street2,
street_line3 street3,
city,
county_code,
county_desc,
state_province state,
postal_code zip,
nation_desc nation,
ROW_NUMBER ()
OVER (PARTITION BY entity_uid
ORDER BY address_type, address_seq_no DESC)
AS rnum
FROM mst_address
WHERE address_type IN ('MA', 'PR')
AND address_status_ind IS NULL
AND SYSDATE BETWEEN NVL (address_start_date, SYSDATE - 1)
AND NVL (address_end_date, SYSDATE + 1)