日期:2014-05-18  浏览次数:20589 次

我这条sql语句写的对么 感觉好像不对

查出c-ip列的个数(去掉重复),同时要保证sc-status列的值必须为200,同时还要保证cs(Referer)列的结尾必须为html或者htm


我的写法如下
SQL code

select COUNT(distinct c-ip) from 表A where sc-status=200 and cs(Referer) like '%.html' or cs(Referer) like '%.htm'



关键是最后的部分不确定是否那么写->or cs(Referer) like '%.htm'

求高手指点!!

------解决方案--------------------
SQL code
select COUNT(distinct c-ip) from 表A where sc-status=200 
and ([cs(Referer)] like '%.html' or [cs(Referer)] like '%.htm')

------解决方案--------------------
SQL code
select COUNT(distinct c-ip) 
from 表A where (sc-status=200 or sc-status=60)
and ([cs(Referer)] like '%.html' or [cs(Referer)] like '%.htm')
--or
select COUNT(distinct c-ip) 
from 表A where sc-status in (200,60)
and ([cs(Referer)] like '%.html' or [cs(Referer)] like '%.htm')

------解决方案--------------------
SQL code
select COUNT(distinct c-ip) 
from 表A where sc-status in (200,60)
and ([cs(Referer)] like '%.html' or [cs(Referer)] like '%.htm'