mysql实现两列数据或者两行数据相减

注意:两行数据相减必须先转子查询,转为两列后,才能进行相减

select (n.a-n.b) as c
from 
(select 
(SELECT settlement_amount FROM `domestic_vendor_statements`
where billing_month='202203') a,
(SELECT settlement_amount FROM `domestic_vendor_statements`
where billing_month='202204') b) as n

在这里插入图片描述

你可能感兴趣的:(Interview,mysql,数据库,database)