Question

Looking for the most expensive order written by LISA WHITE. I think that my problem is in my joining area. Not sure how to go about joining 3 tables together using a structure like this.

TABLE 1 TABLE 2 TABLE 3 Attribute 1--->Attrubute 1
Attribute 2---->Attribute 2

SELECT a.LNAME, a.FNAME, b.TITLE, TO_CHAR(MAX(b.RETAIL), '$99.99') as (Most Exoensive)
FROM AUTHOR a JOIN
      BOOKS b
      using (ISBN)
      b JOIN
      BOOKAUTHOR ba
      using (AUTHORID)
WHERE a.LNAME = 'WHITE' AND a.FNAME = 'LISA'
GROUP BY a.LNAME;
Was it helpful?

Solution

Something like this might work.

select b.title, b.retail
from books b join bookauthor ba using (bookid, authorid)
join author a using (authorid)

join (select max(retail) highestprice
from books bb join bookauthor ba using (bookid, authorid)
join author aa using (authorid)
where aa.lname = 'WHITE' and aa.fname = 'LISA'
group by bb.bookid) temp on retail = highestprice

where a.lname = 'WHITE' and a.fname = 'LISA'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top