[SQL ] 該如何在資料前面加編號
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
07/21 21:01, 1F
Database 近期熱門文章
PTT數位生活區 即時熱門文章