简单的查询
现有一个表table1:
BH SL ZL
A1 1 1.2
A2 0 0
A3 1 0
A4 0 1
A5 2 10
现在想把SL和ZL都等于0的数据过滤了,查询出的数据如下:
BH SL ZL
A1 1 1.2
A3 1 0
A4 0 1
A5 2 10
SQL语句咱写呢?谢谢(在线等)
------解决方案-----------------------例子
create table table1(BH varchar(10), SL int, ZL int)
insert table1
select 'A1 ', 1 , 1.2
union select 'A2 ', 0 , 0
union select 'A3 ', 1 , 0
union select 'A4 ', 0 , 1
union select 'A5 ', 2 , 10
select * from table1 where (sl+zl) <> 0
drop table table1
/*
BH SL ZL
---------- ----------- -----------
A1 1 1
A3 1 0
A4 0 1
A5 2 10
(4 row(s) affected)
*/
------解决方案--------------------如果SL和ZL没有负数的可能
select BH,SL,ZL from table1 where (sl+zl) > 0