首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

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

2012-03-07 
我这条sql语句写的对么 感觉好像不对查出c-ip列的个数(去掉重复),同时要保证sc-status列的值必须为200,同

我这条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')--orselect 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' 

热点排行