[SQL ] 該如何在資料前面加編號

看板Database (資料庫)作者 (暑假到了)時間18年前 (2006/07/21 14:54), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/1
select distinct Customers.CompanyName , UnitPrice * Quantity AS "Total" From Orders INNER JOIN [Order Details] ON [Order Details].OrderID = Orders.OrderID INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID where Orders.OrderDate BETWEEN '1997-01-01' AND '1997-12-31' order by UnitPrice * Quantity DESC 以上是我的程式碼 執行結果為 CompanyName Total -------------------------- Simons bistro 10540.0000 Mere Paillarde 10329.2000 QUICK-Stop 7905.0000 Ernst Handel 6360.0000 ....... 想請問如何能在前面加上編號 ex: NO CompanyName Total -------------------------- 1 Simons bistro 10540.0000 2 Mere Paillarde 10329.2000 3 QUICK-Stop 7905.0000 4 Ernst Handel 6360.0000 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.224.77.229

07/21 21:01, , 1F
#155 篇才有相關的討論的... Orz
07/21 21:01, 1F
文章代碼(AID): #14m7eUNc (Database)
文章代碼(AID): #14m7eUNc (Database)