I want to select the maximum value, but if the user has more than one value in one column, then leave all
I have a table :
create table package (U_id, service, offer,product) as
select 1, 12345, null, null from dual union all
select 1, null, 25468, null from dual union all
select 1, null, null, 23456 from dual union all
select 2, 12345, 58889, null from dual union all
select 2, 43456, null, null from dual ;
I tried
select u_id, max(service), max(offer),max(product)
from package
group by u_id
but, in the case of the second user, took only the maximum number from the service.
I want to get such a table:
u_id | service | offer | product |
---|---|---|---|
1 | 12345 | 25468 | 23456 |
2 | 123456 | 58889 | |
2 | 43456 |