我有一个表和代码,它有点像这样:

--code
SELECT numberA a, numberB B
FROM numbers
;

--table
a : B
2 : 5
3 : 1
2 : 3


但我只想显示A
--table
a : B : diff
2 : 5 : 3
2 : 3 : 1

最佳答案

您可以只添加where条件:

SELECT numberA a, numberB B , numberB - numberA  AS diff
FROM numbers
where numberA < numberB
;

关于mysql - 我只能显示sql中a小于b的行吗?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59400346/

10-11 01:08