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

c# SQL语句 求高手查看
SQL语句如下:目的是在一段时间内数据库中查找不出没有打球的人,即打球次数为零;还望高手看看是那块出问题了,谢啦!

SELECT distinct membername as 姓名,memberstatus as 身份,0 as 打球次数,tb_member.memberjointime as 入会时间 

from tb_member where memberclassification like '授权' and memberstatus!='VIP全免' and memberstatus!='金卡' 

and memberstatus!='嘉宾挂账' and memberstatus!='银卡' and memberstatus!='年度会籍' and memberstatus!='嘉宾' 

and membercerticode not in( SELECT distinct membercerticode FROM (select distinct 

userid ,username,ordernumber,identify from [order] where payed='Y' and ((identify like '%会员%' and identify 

not like '%大青山%' and identify not like '%待遇%')or identify='' or identify='VIP全免' or identify='金卡' or 

identify='嘉宾挂账' or identify='银卡' or identify='年度会籍') and playdate>='2011-12-01' and playdate<='2011-

12-22' and userid in(select membercerticode from tb_member) and username in(select membername from 

tb_member )) as temp join tb_member on temp.userid=tb_member.membercerticode)order by membername desc

------解决方案--------------------
语句嵌套的太多了 最好分几步 或建个视图~~~ 要不看着容易晕~