Re: except all & WITH - syntax error?
От | Tom Lane |
---|---|
Тема | Re: except all & WITH - syntax error? |
Дата | |
Msg-id | 63780.1530544433@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | except all & WITH - syntax error? (pinker <pinker@onet.eu>) |
Ответы |
Re: except all & WITH - syntax error?
|
Список | pgsql-general |
pinker <pinker@onet.eu> writes: > Something strange happened to me right now. I'm trying to compare results > from one query with rewritten version and everything is ok with this order: > WITH abc AS (SELECT 1) SELECT 1 > except all > SELECT 1 > but when I'm trying other way around it throws an error: > SELECT 1 > except all > WITH abc AS (SELECT 1) SELECT 1 You need some parens: # SELECT 1 except all (WITH abc AS (SELECT 1) SELECT 1); ?column? ---------- (0 rows) In your first example, the WITH actually attaches to the whole EXCEPT construct, not the first sub-select as I suspect you're thinking. In short: WITH has lower syntactic precedence than UNION/INTERSECT/EXCEPT. You need parens if you want it to work the other way 'round. regards, tom lane
В списке pgsql-general по дате отправления: