select COUNT(*) from ( select ID,H1 AS Value from Table_1 union all select ID,H2 from Table_1 union all select ID,H3 from Table_1 union all select ID,H4 from Table_1 union all select ID,H5 from Table_1 )as a where ID=1 and Value < 5 select COUNT(*) from ( select ID,H1 AS Value from Table_1 where ID=1 union all select ID,H2 from Table_1 where ID= 1 union all select ID,H3 from Table_1 where ID= 1 union all select ID,H4 from Table_1 where ID= 1 union all select ID,H5 from Table_1 where ID= 1 )as a where Value<5 select * from Table_1 Select Case When H1<5 then 1 else 0 end +Case When H2<5 then 1 else 0 end +Case When H3<5 then 1 else 0 end +Case When H1<5 then 1 else 0 end +Case When H5<5 then 1 else 0 end as 小于5列的个数 from Table_1