sql语句中,select的条件group by having能和where做或运算么?

2024-11-18 13:29:52
推荐回答(2个)
回答(1):

where条件:where user_Id > 30 or time < 3000
group by中having条件: group by field having (user_id>30 or time <3000)

group by having 例子(mysql中验证)
select * from sword_1_instrument
group by dateTime having( value > 1000 or dateTime < '2011-07-12 00:00:00')
order by value desc, dateTime

回答(2):

select *
from table1
group by user_id
having count(user_id) > 30
intersect
select *
from table1
where time < 3000