最好在程序中动态组成SQL 语句:
select * from In_Item_Pro_Dtl 
where PropertyID ='001' and val > 0.0010  --这儿的条件应由程序组合
and PropertyID ='002' and val > 0.0010  
and PropertyID ='004' and val > 0.0020

解决方案 »

  1.   

    是在程序中动态组成SQL语句,PropertyID,val 的值都是由程序中根据用户的选择来组成,但是这条件很难写
    PropertyID ='001' and val > 0.0010  and PropertyID ='002' and val > 0.0010  
    and PropertyID ='004' and val > 0.0020上面条件是不行.
      

  2.   

    一条记录的PropertyID是值只有一个我要的是在同一批号中同时满号上面的三个条件.
      

  3.   

    select * from In_Item_Pro_Dtl 
    where BatchNO in(select BatchNO from In_Item_Pro_Dtl where PropertyID ='001' and val > 0.0010 )
      and BatchNO in(select BatchNO from In_Item_Pro_Dtl where PropertyID ='002' and val > 0.0010 )
       and BatchNO in(select BatchNO from In_Item_Pro_Dtl where PropertyID ='004' and val > 0.0020 )
      

  4.   

    Select distinct m.BatchNo from In_Item_Pro_Mst as m 
    where m.BatchNo in (Select BatchNo=cast 
     when (((d.PropertyID='001') or (d.PropertyID='002'))
      and (d.Val>0.0010))  then d.BatchNo 
     when ((d.PropertyID='004') and (d.Val>0.0020)) then d.BatchNo  
     Else NULL end from In_Item_Pro_Dtl as d )
      

  5.   

    lljianmao(ghost) 方法可行,
    还有其他不同的吗?