Skip to main content
2 of 5
added 156 characters in body

This is an example of pivoting:

select worker_name, max(_in) as _in, max(_out) as _out 
from (
    select worker_name
         , case when in_out = 'IN' then log_time end as _in
         , case when in_out = 'OUT' then log_time end as _out 
    from shift
) as t 
group by worker_name;

The idea is to map log_time to _in when in_out = 'IN', dito for _out. In the outer select an aggregate function is used to filter out nulls. Try running the inner select first to get an idea of what is happening.

In general, presentation is better handled by the application layer, so I would suggest reading the table as is, and do the presentation in the application.