试图找到Oracle SQL中某位作者编写的最昂贵的书

时间:2014-04-23 03:09:47

标签: sql oracle max

寻找LISA WHITE写的最昂贵的订单。我认为我的问题出在我的加盟区域。不知道如何使用这样的结构将3个表连接在一起。

表1表2表3 属性1 --->属性1
               属性2 ---->属性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;

1 个答案:

答案 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'