sql >> Databáze >  >> RDS >> Oracle

ORACLE SQL:Chybí klíčové slovo

Zkuste toto,... Oracle nepodporuje AS pro alias tabulky.

WITH subA AS
       (SELECT customer.first_name
              ,customer.last_name
              ,customer.store_id
              ,film_id
        FROM   (SELECT customer_id
                      ,film_id
                FROM   inventory
                       JOIN (SELECT rental.customer_id
                                   ,rental.inventory_id
                             FROM   rental
                                    JOIN (SELECT customer_id
                                                ,SUBSTR(first_name, 1, 1)
                                                ,SUBSTR(last_name, 1, 1)
                                          FROM   customer
                                          WHERE  SUBSTR(first_name, 1, 1) = SUBSTR(last_name, 1, 1)
                                          AND    customer.store_id = 2) subResults
                                      ON subResults.customer_id = rental.customer_id) subResults2
                         ON inventory.inventory_id = subResults2.inventory_id) finalsubR
               JOIN customer ON customer.customer_id = finalsubR.customer_id)
    ,filmResults AS
       (SELECT *
        FROM   (SELECT title
                      ,rating
                      ,inventory.film_id
                      ,inventory_id
                FROM   inventory JOIN film ON inventory.film_id = film.film_id)
        WHERE  rating = 'PG')
SELECT   DISTINCT first_name
                 ,last_name
                 ,store_id
FROM     subA JOIN filmResults ON subA.film_id = filmResults.film_id
ORDER BY last_name



  1. Zrychlené obnovení databáze v SQL Server 2019

  2. Jak mohu nastavit výchozí úložiště, které používá MySQL?

  3. Pochopení a čtení katalogu systému PostgreSQL

  4. JPA 2:použití více sloupců v cizích klíčích