日期 code count 
18    1    0 
      4    0 
      5    0 
      2    10 
      3    8 
19    4    0 
      5    0 
      1    7 
      2    9 
      3    6 
20    5    0 
      1    8 
      2    5 
      3    6 
      4    7 
我要得到这三天count都不为0的code。我之前的逻辑是基于code是按照正常的顺序排列的,如1、2、3、4、5,我先循环判断这三天的code,如果有一天的不符合要求了,就进行下个code,但是后来看到实际的数据却是code并不是按照之前的顺序,所以再用原来的逻辑就会有问题。请大家帮我解决一下,谢谢.

解决方案 »

  1.   

    select * from t where code not in ( select distinct code from t where count=0 )
      

  2.   

    SELECT * FROM TB WHERE [COUNT]<>0??
      

  3.   

    忘了加日期条件了, 
    select * from t where 日期 between ... and  code not in ( select distinct code from t where count=0 and 日期  between ... ) 
     
      

  4.   

    感谢year2005的帮助,但这个不是数据库表的问题.
      

  5.   

    可以讲这些数值放在dataTable中,按列遍历