Product_Code Month Qty Area CustomerID
------------ ----- --- ---- ----------
820300182 01 1 M1 100078
820300182 01 50 M1 100168
820300182 01 20 M1 100188
820300182 01 10 M1 100618
820300182 01 10 M1 100938
820300182 01 20 M1 100988
820300182 01 25 M1 110158
我希望得到Qty
最低customerID
。
如,
Product_Code Month Qty Area CustomerID
------------ ----- --- ---- ----------
820300182 01 1 M1 100078
答案 0 :(得分:1)
试试这个
Select Qty
from tableName
where CustomerID = ( select min(CustomerID) from tableName )
答案 1 :(得分:1)
假设您要查找CustomerId最低的记录:
SELECT TOP 1 [Product_Code], [Month], [Qty], [Area], [CustomerID]
FROM [TABLE]
ORDER BY [CustomerId] ASC
如果您需要查找数量最少的记录,请将订单更改为
ORDER BY [Qty] ASC