日期:2014-05-17 浏览次数:20517 次
select cu.loginName, count(*) as num from d_order o left join cus_user cu on o.cus_userId=cu.autoId group by cu.loginName order by num desc
--1 select cu.loginName, isnull(count(o.cus_userid),0) as num from d_order o right join cus_user cu on o.cus_userId=cu.autoId and (orderType='ORDER_PRODUCT' or orderType='ORDER_GOODS') and orderStatusForCus='JYWC' group by cu.loginName order by num desc, cu.loginName --2 SELECT cu.loginName, isnull(count(o.cus_userid),0) as num FROM cus_user cu LEFT JOIN ( SELECT cus_userId FROM d_order WHERE (orderType='ORDER_PRODUCT' or orderType='ORDER_GOODS') and orderStatusForCus='JYWC' ) o on o.cus_userId=cu.autoId group by cu.loginName order by num desc, cu.loginName