2016-11-16 27 views

回答

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; 
+0

我可以鱈魚只顯示只有最高成本的記錄 – KAHM

+0

按行刪除命令。並在選擇後添加MAX。 – Kristjan

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

嘗試下面的解決方案,這將工作!

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)