我有两个表要查询。我正在使用:
select timesheet_id, start_time, end_time, break_type, name
from table1, table2
以生成我想要的结果列表。
但是,我还需要从end_time (timestamp)
中减去start_time (timestamp)
,并将结果添加为额外的列。
到目前为止,我只想出了:
select extract(epoch from (end_time - start_time))/60
from table1
以获得减法,但我不知道从两个表中提取数据时如何做到这一点?
这看起来很简单。
您只需在第一个查询中添加secod查询表达式,如下所示:
select timesheet_id, start_time, end_time, break_type, name,
extract(epoch from (end_time - start_time))/60 as diff
from table1, table2