Subquery in from Must Have an Alias

subquery in FROM must have an alias

Add an ALIAS onto 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

POSTGRESQL,subquery in FROM must have an alias


insert into temp_t_so_sales_order_push(so_code,seq)
SELECT t.so_code,nextval('s_t_so_sales_order_push_code') from (
SELECT so_code from t_so_sales_order_push where sync_status = 0 group by so_code
) as t;

(T-SQL) Why does this subquery need an alias?

The alias after the subquery (or derived table, if you prefer) is required by SQL Server. It is not only a requirement but a really good idea. In general, column references should be qualified, meaning that they include a table alias. Without an alias, references to columns in the subquery could not be qualified. I think that's a bad thing.

SQL Server is not the only database that requires the alias. MySQL and Postgres (and hence most Postgres-derived databases) do as well. Oracle and SQLite do not. Nor does Google's BigQuery.

I do not know if the alias is an ANSI/ISO requirement. However, I always use one, regardless of the database.

Postgresql subquery in FROM must have an alias error

inner is a reserved keyword. Use another name as alias.

ERROR: subquery in FROM must have an alias

Just found the solution ! The problem came from the interpretation of query.getSingleResult() which generated a subquery.

I just had to change the dialect used by JPA, in src/main/resources/spring-jpa.xml :

<context:property-placeholder
location="classpath*:jpa-postgresql.properties"
ignore-unresolvable="true" />

With the jpa-postgresql.properties file :

hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
jpa.dialect=org.springframework.orm.jpa.vendor.HibernateJpaDialect
jpa.vendor.adapter=HibernateJpaVendorAdapter

subquery in FROM must have an alias POSTGIS

Seems you did not count ( and ) correctly.
Remove 1 ) right before As f and that should be ok.



Related Topics



Leave a reply



Submit