Why can't use with?

There is here such 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


Why gets the following error?

SQL Error [42P01]: ERROR: table "max" is missing in the FROM clause
 Position: 333
March 23rd 20 at 19:15
1 answer
March 23rd 20 at 19:17
Solution
1) select queries is a mandatory part of from.
2) the Columns in the 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

Find more questions by tags PostgreSQL