Skip to content Skip to sidebar Skip to footer

Sql Min() Returns Multiple Values?

I am using SQL server 2005, querying with Web Developer 2010, and the min function appears to be returning more than one value (for each ID returned, see below). Ideally I would l

Solution 1:

The MIN function returns the minimum within the group. If you want the minimum for each ID you need to get group on just ID. I assume that by "ID" you are referring to Production.WorksOrderOperations.WorksOrderNumber.

You can add this as a "table" in your SQL:

(SELECT Production.WorksOrderOperations.WorksOrderNumber,
       MIN(Production.WorksOrderOperations.OperationNumber) 
  FROM Production.WorksOrderOperations
 GROUPBY  Production.WorksOrderOperations.WorksOrderNumber)

Post a Comment for "Sql Min() Returns Multiple Values?"