sql中有没有方便又好用的减法函数? 比如查询两表总记录数相减的值。

例如:我要算表1的总记录数比表2的总记录数多多少。我现在能想到的语句非常繁琐,有简便的方法吗?比如这样
select count(*) from a
xxx --某个方便又好用的减法函数
select count(*) from b;

阅读 8.2k
1 个回答

可以直接计算

select b.num - a.num from
(select count(*) num from table1) a,
(select count(*) num from table2) b