In a not normalized table structure I need to select the first not empty (length != 0 and not null) column for each zip code.
Table Layout (Both columns are text):
| ZIP | Contact | ...
| 69123 | |
| 69123 | WS |
| 54516 | null |
| 54516 | CS |
| 72226 | RH |
| 72226 | PH |
The Result should look like this:
| ZIP | Contact | ...
| 69123 | WS |
| 54516 | CS |
| 72226 | RH |
Something like this:
SELECT ZIP, fristNotEmpty(Contact)
FROM masterdata GROUP BY ZIP
1 Answer