本文介绍了ORACLE SQL:缺少关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的以下查询引发错误消息错误:ORA-00905:缺少关键字",但可与SQLite一起使用.我找不到错误.
my following query provokes the error message "Error: ORA-00905: missing keyword" but works with SQLite. I can't find the error.
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) as subResults
on subResults.customer_id = rental.customer_id) as subResults2
on inventory.inventory_id = subResults2.inventory_id) as 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
推荐答案
尝试一下,.. Oracle不支持AS作为表别名.
Try this,.. Oracle does not support AS for table alias.
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
这篇关于ORACLE SQL:缺少关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!