0

I have a table similar to this one:

Date     | Cond   | Time
---------+--------+------
18/03/19 |   1    | 13:07
18/03/19 |   0    | 16:07

I want to have a selection that would produce thing similar to that using join or union or any sort of condition

 Date     | Time1 | Time2
----------+-------+------
 18/03/19 | 13:07 | 16:07

Best regards

1
  • Add some more rows with sample table data, and adjust the result if needed. Commented Mar 18, 2019 at 12:16

2 Answers 2

4

You can use conditional aggregation:

select date, max(case when cond = 1 then time end) as time_1,
       max(case when cond = 0 then time end) as time_0
from t
group by date
order by date;
Sign up to request clarification or add additional context in comments.

Comments

0

use aggregate function

select date,min(time),max(time)
from table group by date

1 Comment

For future readers- this only works if there are exactly two values for each date.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.