我需要根據標題總和total_amount。其實我沒有這兩張表之間的關係,但要拿出我需要總結他們和儲蓄兩者總和的差異。我需要總和total_Amount標題=收入和標題=費用
ALTER PROCEDURE [dbo].[SpSavingDetail]
@year varchar(10),
@month varchar(10)
AS
BEGIN
SET NOCOUNT ON;
declare @Saving int
select e.Date_time as Date_time ,c.category as Particular,e.Description as Description ,e.Amount as Amount,
e.Frequency as Frequency,e.Total_Amount as Total_Amount,'Expense' as Title from tbl_expense as e
left join tbl_category as c on c.Cat_id=e.Cat_id where datepart(MM,e.Date_time)[email protected] and datepart(YYYY,e.Date_time)[email protected]
union
select i.Date_time as Date_time ,s.source as Particular,i.Description as Description ,i.Amount as Amount,
i.Frequency as Frequency,i.Total_Amount as Total_Amount,'Income' as Title from tbl_income as i
left join tbl_source as s on s.Source_id=i.Source_id
where datepart(MM,i.Date_time)[email protected] and datepart(YYYY,i.Date_time)[email protected]
[1]: http://i.stack.imgur.com/8Z5po.jpg
這是怎麼C#代碼? –
其存儲過程,我在報告中使用 – abcd