PostgreSQL
 sql >> Datenbank >  >> RDS >> PostgreSQL

Unterabfrage in FROM muss einen Alias ​​haben

Fügen Sie einen ALIAS hinzu auf die Unterabfrage

SELECT  COUNT(made_only_recharge) AS made_only_recharge
FROM    
    (
        SELECT DISTINCT (identifiant) AS made_only_recharge
        FROM cdr_data
        WHERE CALLEDNUMBER = '0130'
        EXCEPT
        SELECT DISTINCT (identifiant) AS made_only_recharge
        FROM cdr_data
        WHERE CALLEDNUMBER != '0130'
    ) AS derivedTable                           -- <<== HERE