I have a table MNO like this:-
key open mode close time
1 112 O 10:15pm
1 C 200 11:50pm
我想查询输出给我这个: -
key open close difference open_time close_time
1 112 200 88 10:15pm 11:50pm
答案 0 :(得分:2)
select
o.key, o.open, c.close,
c.close - o.open as difference,
o.time as open_time,
c.time as close_time
from
mno o
mno c
where
o.key = c.key
and o.mode='O'
and c.mode='C'
;