This is my data:
| ACCOUNT | PARTNER | ADDRS_NUM |
|---|---|---|
| HL124 | 2341 | ASD123 |
| HL124 | 2341 | SDF234 |
| HL124 | 234N | SDF234 |
| HG225 | 45BV | QWE345 |
| HG225 | 72AA | QWE345 |
| UY150 | 8846 | CCC204 |
Need to get ACCOUNT that has more than one PARTNER & ADDRS_NUM are different.
In above case, only we need to get HL124
I tried select query and then thought of filtering on the counts, but select gives weird o/p and also taking time.
SELECT
COUNT(ACCOUNT) OVER (PARTITION BY ACCOUNT),
COUNT(PARTNER) OVER (PARTITION BY ACCOUNT),
COUNT(ADDRS_NUM) OVER (PARTITION BY ACCOUNT)
FROM
table
Would like to know efficient way to get result.
You can use 1 window function for account and another to filter PARTNER & ADDRS_NUM multiple values -
Demo.