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

统计并过滤重复记录如何写

2012-01-21 
统计并过滤重复记录怎么写selectcount(csl_orders_goods)asidcountfrom(selectdistinct(csl_orders_goods)

统计并过滤重复记录怎么写
select   count(csl_orders_goods)   as   idcount   from   (select   distinct(csl_orders_goods)   from   chinashowlace_orders   where   csl_orders_userid= "&session( "csl_user_id ")& ")
我现在有统计应该有三条记录为什么没呢

[解决办法]
try

select count(distinct csl_orders_goods) as idcount from chinashowlace_orders where csl_orders_userid= "&session( "csl_user_id ")& "
[解决办法]
select count(csl_orders_goods) as idcount from
(
select distinct(csl_orders_goods) as csl_orders_goods from chinashowlace_orders where csl_orders_userid = "&session( "csl_user_id ")& " --这里加入变量
) t

[解决办法]
子查询要有别名的,没有别名能运行??

热点排行