In SQL Server 2008 I have a table CUSTOMERS that has two columns as:
ID,
BALANCE
How can I write the query that selects the ID of the customer who has maximum balance, "in the most effective way"?
Option 1: ORDER BY BALANCE and SELECT TOP(1)
--> costs too much.
Option 2: Firstly Get MAX amount
, then make another query that uses the amount in where clause
--> costs too much and not seem reliable.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…