Hi , I have complex data base
I want to get debit from rang date and debit to another rang gate for some of account in finance application

I use the below script

SELECT DISTINCT
Acc_2.Acc_ID, SUM(JournalVoucher_1.Creditor) AS Credit, SUM(JournalVoucher_1.Debit) AS Debit, Acc_2.Acc_Name, SUM(JournalVoucher_1.OtherCreditor)
AS OtherCredit, SUM(JournalVoucher_1.OtherDebit) AS OtherDebit,
(SELECT SUM(JournalVoucher_1.Creditor) AS Expr1
FROM dbo.JournalVoucher AS JournalVoucher_1 INNER JOIN
dbo.Acc AS Acc_1 ON JournalVoucher_1.AccNum = Acc_1.Acc_ID RIGHT OUTER JOIN
dbo.Acc AS Acc_2 ON Acc_1.Main_ID = Acc_2.Acc_ID
WHERE (JournalVoucher_1.JVDate BETWEEN '2013-01-01' AND '2013-09-05')
GROUP BY Acc_2.Acc_ID) AS Credit1,
(SELECT SUM(JournalVoucher_1.Debit) AS Expr2
FROM dbo.JournalVoucher AS JournalVoucher_1 INNER JOIN
dbo.Acc AS Acc_1 ON JournalVoucher_1.AccNum = Acc_1.Acc_ID RIGHT OUTER JOIN
dbo.Acc AS Acc_2 ON Acc_1.Main_ID = Acc_2.Acc_ID
WHERE (JournalVoucher_1.JVDate BETWEEN '2013-01-01' AND '2013-09-05')
GROUP BY Acc_2.Acc_ID) AS Debit1,
(SELECT SUM(JournalVoucher_1.OtherCreditor) AS Expr2
FROM dbo.JournalVoucher AS JournalVoucher_1 INNER JOIN
dbo.Acc AS Acc_1 ON JournalVoucher_1.AccNum = Acc_1.Acc_ID RIGHT OUTER JOIN
dbo.Acc AS Acc_2 ON Acc_1.Main_ID = Acc_2.Acc_ID
WHERE (JournalVoucher_1.JVDate BETWEEN '2013-01-01' AND '2013-09-05')) AS OtherCreditor1,
(SELECT SUM(JournalVoucher_1.OtherDebit) AS Expr2
FROM dbo.JournalVoucher AS JournalVoucher_1 INNER JOIN
dbo.Acc AS Acc_1 ON JournalVoucher_1.AccNum = Acc_1.Acc_ID RIGHT OUTER JOIN
dbo.Acc AS Acc_2 ON Acc_1.Main_ID = Acc_2.Acc_ID
WHERE (JournalVoucher_1.JVDate BETWEEN '2013-01-01' AND '2013-09-05')) AS OtherDebit1
FROM dbo.JournalVoucher AS JournalVoucher_1 INNER JOIN
dbo.Acc AS Acc_1 ON JournalVoucher_1.AccNum = Acc_1.Acc_ID RIGHT OUTER JOIN
dbo.Acc AS Acc_2 ON Acc_1.Main_ID = Acc_2.Acc_ID

WHERE (JournalVoucher_1.JVDate BETWEEN '2013-09-06' AND '2013-09-10') OR
(JournalVoucher_1.JVDate IS NULL)
GROUP BY Acc_2.Acc_ID, Acc_2.Acc_Name, Acc_2.Acc_Lvl, JournalVoucher_1.JVDate
HAVING (Acc_2.Acc_Lvl = 1)


but the result wrong
put the sum in all rows not in correct row
how I can fix it