subquery in FROM must have an alias

后端 未结 2 1890
青春惊慌失措
青春惊慌失措 2020-11-30 03:48

I have this query I have written in PostgreSQL that returns an error saying:

[Err] ERROR:
LINE 3: FROM (SELECT DISTINCT (identifiant) AS made_on

相关标签:
2条回答
  • 2020-11-30 04:04

    In the case of nested tables, some DBMS require to use an alias like MySQL and Oracle but others do not have such a strict requirement, but still allow to add them to substitute the result of the inner query.

    0 讨论(0)
  • 2020-11-30 04:24

    add an ALIAS on the subquery,

    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
    
    0 讨论(0)
提交回复
热议问题