Answer the question
In order to leave comments, you need to log in
Why can't use with?
There is this request:
with min as
(
select
cast(extract(epoch from time) as integer)
from records
where time >= '2016-01-01 06:36:12'
order by time asc
limit 1
), max as (
select
cast(extract(epoch from time) as integer)
from records
where time <= '2016-02-01 06:36:12'
order by time desc
limit 1
)
select (max.time - min.time) t1
SQL Error [42P01]: ОШИБКА: таблица "max" отсутствует в предложении FROM
Позиция: 333
Answer the question
In order to leave comments, you need to log in
1) Select queries have a mandatory from part.
2) Columns in tables are not named
Try this:
with min as
(
select
cast(extract(epoch from time) as integer) as time
from records
where time >= '2016-01-01 06:36:12'
order by time asc
limit 1
), max as (
select
cast(extract(epoch from time) as integer) as time
from records
where time <= '2016-02-01 06:36:12'
order by time desc
limit 1
)
select (max.time - min.time) t1
from min, max
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question