寻找LISA WHITE写的最昂贵的订单。我认为我的问题出在我的加盟区域。不知道如何使用这样的结构将3个表连接在一起。
表1表2表3 属性1 --->属性1SELECT 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;
答案 0 :(得分:0)
这样的事情可能有用。
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'