sql where判断语句问题

来源:百度知道 编辑:UC知道 时间:2024/06/10 14:47:30
打个比方:我要查询select 1,2 from *时,由于在查询2时有判断条件,所以我想到了在后面添加where判断语句,但是我只需要他为2做判断而不需要同时给1也做判断,请问这样的判断语句怎么写?
如果其中2的语句是count(*) 那我where后面该怎么写? 注意我的补充..下面说的2种的不可以啊

是否表中第1列不动,第2列按条件显示? :
select 1,(case when 2的判断条件 then 满足条件返回的值 end)as 2
from 表

如果2的语句是count(*) :
select 1,sum(case when 2的判断条件 then 1 end)as 2的统计结果
from 表
group by 1

select name,count(*) as num
from table
group by name
having count(*) > 100
查询该用户在本表的出现次数

select 1,2 from xxxx where 2.......
直接写2的条件就OK了啊

select 列名A,列名B from 表A where 列名B>条件

select 1,2 from T group BY 1 HAVING 2>?