Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- email_address | brand | region | area | site | lowest_distinct_level
- ----------------|-------|--------|------|------|----------------------
- alpha@gmail.com | 1 | 1 | 1 | 2 |
- beta@gmail.com | 1 | 1 | 2 | 0 |
- gamma@gmail.com | 1 | 1 | 2 | 2 |
- zeta@gmail.com | 1 | 2 | 0 | 0 |
- select email_address, brand, region, area, site,
- case when site = 1 then 'site'
- else case when area = 1 then 'area'
- else case when region = 1 then 'region'
- else case when brand = 1 then 'brand'
- else ''
- end
- end
- end
- end
- from mm;
- +-----------------+-------+--------+------+------+-----------------------+
- | email_address | brand | region | area | site | lowest_distinct_level |
- +-----------------+-------+--------+------+------+-----------------------+
- | alpha@gmail.com | 1 | 1 | 1 | 2 | area |
- +-----------------+-------+--------+------+------+-----------------------+
- | beta@gmail.com | 1 | 1 | 2 | 0 | region |
- +-----------------+-------+--------+------+------+-----------------------+
- | gamma@gmail.com | 1 | 1 | 2 | 2 | region |
- +-----------------+-------+--------+------+------+-----------------------+
- | zeta@gmail.com | 1 | 2 | 0 | 0 | brand |
- +-----------------+-------+--------+------+------+-----------------------+
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement