Nero
Nero

Reputation: 592

Select from the result of a union query, Oracle

I am trying to do a select on the result of a union. I am running Oracle 11g. I ran the following query and I get ORA-00933: SQL command not properly ended

I looked at a lot of other posts and this should work, however it doesn't for me. Any help will be appreciated.

SELECT tbl.name
FROM
(
    SELECT name FROM customer
    UNION
    SELECT name FROM vendor
) AS tbl;

Upvotes: 1

Views: 4081

Answers (2)

Gordon Linoff
Gordon Linoff

Reputation: 1269463

Oracle doesn't support as for table aliases. So, just remove it:

SELECT tbl.name
FROM (SELECT name FROM customer
      UNION
      SELECT name FROM vendor
     ) tbl;

Upvotes: 2

Vamsi Prabhala
Vamsi Prabhala

Reputation: 49260

Remove as.

SELECT tbl.name
FROM
(
    SELECT name FROM customer
    UNION
    SELECT name FROM vendor
) tbl

Upvotes: 4

Related Questions