Click here to Skip to main content
15,917,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I Have have two tables income table and expense table in which i want to search a total income and expenses between two date if between this date on a particular date its not contain any income or expense so it should show that date and amount to 0. Is it possible ?
Posted
Updated 18-Apr-14 2:30am
v2

Try:
SQL
SELECT SUM(Income), SUM(Expense) FROM MyTable WHERE insertDate BETWEEN '2014-01-01' AND '2014-02-01'
 
Share this answer
 
Try:

Select case when tblincome.date is null and tblexpense.date is not null then tblexpense.date 
            when tblincome.date is not null and tblexpense.date is null then tblincome.date 
            when tblincome.date is not null and tblexpense.date is not null then tblincome.date 
       end as Date,
Sum(tblincome.income), Sum(tblexpense.expense) from tblincome full join tblexpense
ON tblincome.date =  tblexpense.date
where tblincome.date between '2014-01-01' AND '2014-02-01'
 
Share this answer
 
Comments
duke90 19-Apr-14 2:07am    
its not working as i expected but somehow it helped me....
duke90 19-Apr-14 2:48am    
i did bit change in it now its working fine.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900