I am an Oracle SQL beginner and I have an issue with the code below:
SELECT unique_id,
CASE
WHEN type LIKE 'E-%' THEN
'electric'
ELSE
null
END electric_flag,
CASE
WHEN type LIKE 'G-%' THEN
'gas'
ELSE
null
END gas_flag,
CASE
WHEN type LIKE 'W-%' THEN
'water'
ELSE
null
END water_flag,
CASE
WHEN type LIKE 'S-%' THEN
'wastewater'
ELSE
null
END wastewater_flag
FROM (SELECT unique_id, type, end_dt
FROM table
WHERE end_dt IS NULL)
Which gives me the following results:

My goal is to have the results show like this:

It's almost like I want to group the results by the id, ignore rows that are all null, but combine the rows that return with the flag into a single row.
Any help would be greatly appreciated!