Another couple options:declare @t table (rowid int identity(1,1), n1 int, n2 int, n3 int, n4 int, [min] int)insert @t (n1,n2,n3,n4,[min])select 1,1,1,2,1 union allselect 1,2,3,4,2 union allselect 2,3,4,5,2 union allselect 3,4,5,6,4--2005 or later--This solution assumes you have some row identifierselect * from @twhere rowid in ( select rowid from @t unpivot (n for col in ([n1],[n2],[n3],[n4]) ) up group by rowid having min(n) != min([min]) )--any versionselect n1,n2,n3,n4,[min]from @twhere [min] > n1or [min] > n2or [min] > n3or [min] > n4OUTPUT:rowid n1 n2 n3 n4 min----------- ----------- ----------- ----------- ----------- -----------2 1 2 3 4 24 3 4 5 6 4n1 n2 n3 n4 min----------- ----------- ----------- ----------- -----------1 2 3 4 23 4 5 6 4
EDIT:This is a good example of why you should normalize your data. One column of numbers and one column to identify the type. Then you don't need to store the min of the values - just derive it at runtime.Be One with the OptimizerTG