34,873
社区成员
发帖
与我相关
我的任务
分享
select u.nickname,u.uid,(select count(1) from tbl_daily d where d.D_Uid=u.uid AND '2012-02-14'<=d.D_Submitted and d.D_Submitted<='2012-02-15')
as cnt from dnt_users u where u.groupid in(1,14,15,8,3,18) group by u.username;
select u.nickname,u.uid,
case when (select count(1) from tbl_daily d
where d.D_Uid=u.uid AND '2012-02-14'<=d.D_Submitted and d.D_Submitted<='2012-02-15')=0
then 1 else 0 end as 'cnt'
from dnt_users u
where u.groupid in(1,14,15,8,3,18)
group by u.username;
select u.nickname,u.uid,isnull(d.cnt,0) as cnt
from dnt_users u
left join
(select D_Uid,count(1) as cnt from tbl_daily
'2012-02-14'<=d.D_Submitted and d.D_Submitted<='2012-02-15'
) d
on d.D_Uid=u.uid AND
where u.groupid in(1,14,15,8,3,18)