如下SQL:
select nx,nx as nx1,ggdm,gg,MD, GL,CPB,count(*) as sl,bz,bz as je,'0' as ls into zjhzb from  (select Modelcode,(select CPGrade from t_ProductInfo where CPModel=a.Modelcode) as nx, (select GGID from tp_Standard where GGID=(select CPStandardID from t_ProductInfo where CPModel=a.Modelcode)) as ggdm, (select GGName from tp_Standard where GGID=(select CPStandardID from t_ProductInfo where CPModel=a.Modelcode)) as gg, (select CPMendCash from t_ProductInfo where CPModel=a.Modelcode) as bz , (select CPForcedValue from t_ProductInfo where CPModel=a.Modelcode) as GL , (select CPBrand from t_ProductInfo where CPModel=a.Modelcode) as CPB , (select CPModel from t_ProductInfo where CPModel=a.Modelcode) as MD  from t_Itemlist as a  where ((ReportYear=0 or ReportYear=2010 or reportyear is null)) and (ReportMonth in (0)) and (SaleMode is null or SaleMode<>'退货')and (BuyerAreaID like '11*')  ) as aa group by nx,ggdm,gg,bz,GL,CPB,MD

解决方案 »

  1.   

    刚才着急,发帖的时候写的乱,整理后如下:
    select nx,nx as nx1,ggdm,gg,MD, GL,CPB,count(*) as sl,bz,bz as je,'0' as ls into zjhzb from  
    (select Modelcode,(select CPGrade from t_ProductInfo where CPModel=a.Modelcode) as nx, 
    (select GGID from tp_Standard where GGID=(select CPStandardID from t_ProductInfo where CPModel=a.Modelcode)) as ggdm, 
    (select GGName from tp_Standard where GGID=(select CPStandardID from t_ProductInfo where CPModel=a.Modelcode)) as gg, 
    (select CPMendCash from t_ProductInfo where CPModel=a.Modelcode) as bz , 
    (select CPForcedValue from t_ProductInfo where CPModel=a.Modelcode) as GL , 
    (select CPBrand from t_ProductInfo where CPModel=a.Modelcode) as CPB , 
    (select CPModel from t_ProductInfo where CPModel=a.Modelcode) as MD  from t_Itemlist as a  
    where 
    ((ReportYear=0 or ReportYear=2010 or reportyear is null)) 
    and (ReportMonth in (0)) 
    and (SaleMode is null or SaleMode<>'退货')
    and (BuyerAreaID like '11*')  ) 
    as aa group by nx,ggdm,gg,bz,GL,CPB,MD
    如果去掉and (BuyerAreaID like '11*')就可以查到数据,请高手帮忙
      

  2.   

    这个我试过了,我当初写的就是%,但不行,查了,Access只能用*代替%,所以就改成*了,但还是不行
      

  3.   

    不可能啊。。我access都是用%号的。。like '11'%''  
      

  4.   

    BuyerAreaID 是字符类型字段吗
      

  5.   

    去掉这句and (BuyerAreaID like '11*') 有查询结果吗?