本文介绍了如何在单个查询中以百分比形式从两个不同的表中计算总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须以百分比形式计算从费用表中收取的月费和发票表中的剩余费用
I have to calculate monthly fees collected from fees table and remaining fees from invoice table in percentage form
推荐答案
WITH MonthlyFee
AS (
SELECT
SUM(fee) AS MonthlyFees -- Query to calculate monthly fee percentage
FROM
Fee
),
RemainingFee
AS (
SELECT
SUM(fee) AS RemainingFees -- Query to calculate Remaining Fees percentage
FROM
Invoice
)
SELECT
MonthlyFees,RemainingFees
FROM
MonthlyFee,
RemainingFee;
这篇关于如何在单个查询中以百分比形式从两个不同的表中计算总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!