Query:

select machinename, StatusCode, max(size) as size, statusID
from machine where MachineID In( '33','22') and StatusCode = 166 
group by machinename, StatusCode, statusID
order by max(size) DESC

Result:

   machinename  StatusCode  size statusID
    -----------  ----------  ---- --------
    test1        166         50       1
    test1        166         25       2
    test2        166         75       3
    test2        166         48       4

Requirement:

I have to display just one entry for every machine. I must do that if you take the max size value between your two records as proven above. like for test1 i've two dimensions 50 and 25 I must show the row that has 50 and ignore row that has 25.

Thanks

Preferred Result:

 machinename  StatusCode  size statusID
    -----------  ----------  ---- --------
    test1        166         50       1  
    test2        166         75       3 
SELECT machinename, StatusCode, size, statusID
FROM (
    SELECT
        machinename,
        StatusCode,
        size,
        statusID,
        ROW_NUMBER() OVER (PARTITION BY MachineID ORDER BY size DESC) AS rn
    FROM machine
    WHERE MachineID IN ('33','22')
    AND StatusCode = 166 
) T1
WHERE rn = 1
ORDER BY size DESC 

Three solutions for "old" SQL Server s:

SELECT  *
FROM    TestData a
WHERE   a.Size >= ALL(SELECT b.Size FROM TestData b WHERE b.MachineName=a.MachineName);

SELECT  *
FROM    TestData a
WHERE   a.Size = (SELECT MAX(b.Size) FROM TestData b WHERE b.MachineName=a.MachineName);

SELECT  a.*
FROM    TestData a
JOIN    (SELECT MachineName, MAX(Size) MaxSize FROM TestData GROUP BY MachineName) b 
ON      a.MachineName=b.MachineName 
AND     a.Size=b.MaxSize;

Results:

MachineName StatusCode  Size        StatusID
----------- ----------- ----------- -----------
test2       166         75          3
test1       166         50          1

Warning: if you will find many rows with similar maximum value for any machine, then each one of these queries can have these rows.