. Advertisement .
..3..
. Advertisement .
..4..
Hi developer experts, I have a small but frustrating use case, and so far, I couldn’t get my head around this problem & ideal solution. I am running my command and facing one problem with the subquery in from must have an alias. Below is the command I used:
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'
)
When I run it, I get the following error:
[Err] ERROR:
LINE 3: FROM (SELECT DISTINCT (identifiant) AS made_only_recharge
I am looking forward to gaining some knowledge from all experts. Thank you, guys!
The cause:
In the FROM clause, you did not set for the subquery an alias (such as a name), so it could not be identified in the query and the error happened.
Solution:
You can fix this error by adding an
ALIAS
to the subquery in the FROM clause as following:Some DBMS require nested tables to be named MySQL or Oracle, while others don’t have this strict requirement but allow you to add them to replace the inner query.