Skip to content
Advertisement

group by date and show the values of X(column) which depends on min time of that date and max time of that date in 1 row

I have table like

I want to group by date which user has the id of u_id =1 and get first time and value of x and get the last time and value of x in same row

it should be like

what i’ve tried

but i cant get the values of xs.

the rows:

enter image description here

Advertisement

Answer

One method uses conditional aggregation:

You can also phrase the conditional aggregation as:

Another method uses arrays:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement