Sample Header Ad - 728x90

WITH ... AS statement not working as expected

3 votes
2 answers
2648 views
I get this error: WITH...AS syntax error It arises when I try to execute the following query:
with expensive_service as (
    select s1.*
    from service s1, service s2
    where s1.price > s2.price
)
select * 
from service except expensive_service;
I was trying to implement WITH ... AS (link to PostgreSQL docs). This query gives me the desired output I'm looking for:
select * 
from service except ( 
    select s1.*
    from service s1, service s2
    where s1.price > s2.price
)
Any aid directing me where the error lies would be greatly appreciated!
Asked by FernandoH-G (33 rep)
Mar 23, 2020, 07:24 AM
Last activity: Apr 3, 2020, 11:41 PM