I am pretty new to SQL and am trying to only display the one category which has the most expensive book. My first idea was to remove max(books.purchase_price)
from select
and add max(books.purchase_price) = books.purchase_price
to the where
section. But that gives me an error message.
select categories.category, max(books.purchase_price) as price
from books, categories
where categories.category_id = books.category_id
group by categories.category
order by pris desc
limit 1
There are only two tables: books
which have entries with titles, prices and category_id
; and categories
which have category_id
and the different categories (names).