Home > Software design >  Wrapping query as an inline view not working in PostgreSQL
Wrapping query as an inline view not working in PostgreSQL

Time:10-15

In SQL Cookbook and example is given of wrapping query as inline view. Tried in pgadmin but got error. Simplified but still got error. Syntax error at or near SELECT.

SELECT * FROM (SELECT prod_id, prod_price FROM Products)

(SELECT prod_id, prod_price FROM Products of course works)

Any help appreciated!

CodePudding user response:

The derived subquery requires an alias:

SELECT * FROM (SELECT prod_id, prod_price FROM Products) t;
                                                      -- ^^ change is here
  • Related