This is my current table, let’s call it “TABLE”
I want end result to be:
I tried this query:
SELECT * FROM TABLE GROUP BY(service)
but it doesn’t work
i tried replacing NULL with 0 and then perform group by but “TBA” (text value) is creating problem, kindly help me out!
Advertisement
Answer
This looks like simple aggregation:
select service, max(for1) for1, max(for2) for2, max(for3) for3 from mytable group by service
This takes advantage of the fact that aggregate functions such as max()
ignore null
values. However if a column has more than one non-null
value for a given service
, only the greatest will appear in the resultset.
It is unclear what the datatype of your columns is. Different datatypes have different rules for sorting.