列出出版商ID,出版商名称,最高价格书籍的标题和价格
表1
Books
.ISBN
.Title
.PubDate
.PubID
.Cost
.Retail
.Category
表2
Publisher
.PubId
.Name
.Contact
.Phone
答案 0 :(得分:2)
尝试下面的解决方案,那会有效!
SELECT tbl1.pubID as 'Publisher ID',
tbl2.Publisher as 'Publisher Name',
tbl1.Title,
tbl1.Cost
FROM tables1 tbl1
INNER JOIN tables2 tbl2 ON tbl1.pubID = tbl2.pubID
WHERE tbl1.Cost IN (SELECT MAX(tt.Cost) FROM tables1 tt)
答案 1 :(得分:1)
SELECT top 1 tbl1.pubID as 'Publisher ID',
tbl2.Publisher as 'Publisher Name',
tbl1.Title,
tbl1.Cost
FROM tables1 tbl1
INNER JOIN tables2 tbl2 ON (tbl1.pubID = tbl2.pubID)
ORDER BY tbl1.cost DESC
答案 2 :(得分:0)
SELECT tbl1.pubID as 'Publisher ID', tbl2.Publisher as 'Publisher Name', tbl1.Title, tbl1.Cost
FROM tables1 tbl1 INNER JOIN tables2 tbl2 ON (tbl1.pubID = tbl2.pubID)
ORDER BY tbl1.cost DESC;