select x.col1 ,x.col2 ,x.col3 ... from (select distinct col1,col2,col3 .... from yourtable where oderflag <> 0 ) x where not exists (select 1 from yourtable y where y.oderflag =0 and y.col1=x.col1 and y.col2=x.col2 and y.col3 =x.col3...)
select @num=count(*) from table where condition='..' and oderflag<>0
select @num1=count(*) from table where condition='..'
if (@num=@num1)
print '全不为0'
select x.col1 ,x.col2 ,x.col3 ... from (select distinct col1,col2,col3 .... from yourtable where oderflag <> 0 ) x where not exists (select 1 from yourtable y where oderflag =0 and y.col1=x.col1 and y.col2=x.col2 and y.col3 =x.col3...)