Click here to Skip to main content
15,908,776 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I have 2 Tables
1. tbl_Bill
2. tbl_Payment

i want to get data from this 2 tables
from tbl_Bill - Billed Amount and Billed Date
from tbl_Payment - Paid Amount and Paid Date

i want to get datas between from date and to date

i have datas from novemer2013 to till date both billed amount and paid amount
if i give 01.01.2014 as start date and 12.02.2014 as to date,
then i want get the total billed amount and paid amount then get a
outstanding(Billed Amount Total - Paid Amount Total) From 01.11.2013(Nov) to 31.12.2014 

Then need to show like this

Company Outstanding (15000.00)(as on 31.12.2013)
SINo   Billed Amt   Billed Date     Recived Amt     Received Date  
 1	500.00	     10.01.2014        --           --
 2	250.00	     20.01.2014        --	    --
 3	--	     --		       250.00	    21.01.2014
 4	200.00 	     22.01.2014        ---	    --
 5	--	     --                150.00 	    01.02.2014
 --------------------------------------------------------------
Total   950.00			       400.00
				   Total Outstanding : 15550
Posted
Comments
santhu888 12-Feb-14 1:27am    
You want to show this output in database itself or in C#????
chinna_soft 14-Feb-14 0:17am    
Thank you for your replay.. Data Base itself
midnight_ 12-Feb-14 1:28am    
Check this: http://technet.microsoft.com/de-de/library/ms187810.aspx
chinna_soft 14-Feb-14 0:27am    
its working but i cant avoid duplicate datas. my coding
ALTER PROCEDURE [dbo].[Sample1]
@Customer varchar(200),
@StartDate varchar(50),
@EndDate varchar(50)
AS
SET NOCOUNT ON

select max(b.Customer)Customer,max(b.GrandTotal)BilledAmt, max(b.BillDate) BillDate,max(p.ReceviedAmt) RAmt,max(p.RDate) RDate from tbl_TotalBill b full outer join tbl_SalesPayment p
on p.customer=b.customer
where b.Customer=@Customer
and p.RDate between @StartDate and @EndDate
and b.BillDate between @StartDate and @EndDate
GROUP BY b.Id,p.Id
santhu888 12-Feb-14 1:35am    
K company outstanding column is another table column?? if ,what was the relation b/w these three tables?

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