Home > Software engineering >  What is the TABLE keyword for in this CTE expression
What is the TABLE keyword for in this CTE expression

Time:11-06

in this I post came across this weird postgres query:

WITH max_i AS
  ( SELECT MAX(i) FROM test )
SELECT *
FROM test
WHERE i = (TABLE max_i) - 1 ;

It was able to use the CTE return value like a simple variable through the use of the TABLE keyword. I looked through the documentation of postgres, but I couldn't find any mention of what it is or what it is used for. Can someone explain to me how it works?

CodePudding user response:

It's a short way of writing

select * from max_i

See the manual for details

  • Related