Here is my the Problem: List the title_id, pubdate and month name (e.g., ‘May’) that has the most published books.
I’m on Oracle 10g express.
Here is my query:
SELECT count(EXTRACT(MONTH FROM pubdate)), title_id
CASE EXTRACT(MONTH FROM pubdate)
WHEN 2 THEN 'February'
WHEN 3 THEN 'March'
WHEN 4 THEN 'April'
WHEN 5 THEN 'May'
WHEN 6 THEN 'June'
WHEN 7 THEN 'July'
WHEN 8 THEN 'August'
WHEN 9 THEN 'September'
WHEN 10 THEN 'October'
WHEN 11 THEN 'November'
WHEN 12 THEN 'December'
END
FROM titles t, publishers p
WHERE t.pub_id=p.pub_id
AND pubdate in
(select max(EXTRACT(MONTH FROM pubdate)) from titles group by t.title_id)
GROUP BY t.title_id
ORDER BY count(EXTRACT(MONTH FROM pubdate));
In Oracle it is telling me that there is a FROM keyword expected not found. Any experts can look at this and tell me where I’m wrong?
You’re missing a comma between
title_id and CaseInterestingly if you use Instant SQL Formatter
You get a much better error message