Hãy thử điều này, .. Oracle không hỗ trợ AS cho bí danh bảng.
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