2014-08-27 191 views
1

我想如下創建視圖:試圖創建一個視圖

CREATE OR REPLACE VIEW film_list 
AS 
SELECT 
    film.film_id AS FID, film.title AS title, film.description AS description, 
    category.name AS category, film.rental_rate AS price, 
    film.length AS length, film.rating AS rating, 
    LISTAGG(actor.first_name ||' '|| actor.last_name, ', ') WITHIN GROUP AS actors 
FROM 
    category LEFT JOIN film_category ON category.category_id = film_category.category_id 
       LEFT JOIN film ON film_category.film_id = film.film_id 
         JOIN film_actor ON film.film_id = film_actor.film_id 
         JOIN actor ON film_actor.actor_id = actor.actor_id 
GROUP BY 
    film.film_id, film.title, film.description, category.name, 
    film.rental_rate, film.length, film.rating; 

它給FOLL以下錯誤:

Error at line 1 
ORA-00906: missing left parenthesis 

而且我看不出有任何的右括號開放,你的幫助將非常感謝! 感謝

回答

3

你在行收到錯誤:

LISTAGG(actor.first_name ||' '|| actor.last_name, ', ') WITHIN GROUP AS actors 

改變它的東西,如:

LISTAGG(actor.first_name ||' '|| actor.last_name, ', ') WITHIN GROUP (ORDER BY actor.first_name) AS actors 
1

WITHIN GROUP具有by子句用括號括起的訂單。見here