What I have is a table which has the prices of book titles. What I'm trying to do is to list the book titles that have a greater than average price. What I have so far is :
SELECT TITLES.PRICE, AVG(TITLES.PRICE) AS "KOMPARE"
FROM TITLES,
(SELECT PRICE, AVG(PRICE)
FROM TITLES
GROUP BY Price) subquery1
WHERE TITLES.PRICE = subquery1.PRICE
AND subquery1.PRICE > TITLES.KOMPARE
GROUP BY TITLES.PRICE;
The error that I am getting is that TITLES.KOMPARE
is a invalid identifier. I'm not sure why as I defined it in the first select statement. And it's not like I could put AVG(TITLES.PRICE)
in the AND
statement. I would be forever thankful for anyone who can offer me some advice! Thank you.
FYI my table name is TITLES, and the prices of the books are PRICE.