select 里怎么按计算后的结果过滤

来源:百度知道 编辑:UC知道 时间:2024/06/07 13:55:28
select a,b,a-b as c from tb1

我想过滤掉c<=0的数据,怎么过滤?
多谢谢shaoshuai_bd,但是A,B各是用Sum得来的结果,很耗资源的,,有没有节省点资源的方法?

select a,b from tb1 where a>b
如果必须使用c
select a,b,a-b as c from tb1 where a>b

在数据结构不改的情况下,要进行 SQL优化,方便的话,把完整的SQL给我看看。如不方便公开可以用消息的方法给我。

select a,b,a-b as c from tb1 where c<=0

这样试试

不嫌麻烦的话在你查询得出的结果集上建立视图,之后的操作就在这个视图上进行就行了!

select a,b,a-b as c from tb1 where a-b<=0

select a,b,a-b as c from tb1 where c>0