sql 查询多列 小于某值
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
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步