Hi
I have below Data returned by query and i want to display Opening Balance.
I have following table named table1 with following data
Ac# Date Debit Credit
1 1-Jan-15 100
1 1-Jan-15 100
1 2-Jan-15 200
1 2-Jan-15 300
1 3-Jan-15 200
1 3-Jan-15 100
Now User gives parameter date range as following Date >= 2-Jan-15 and Date<= 3-Jan-15 Now the data will be display in report as following
Ac# Date Debit Credit
Op Bal 200
1 2-Jan-15 200
1 2-Jan-15 300
1 3-Jan-15 200
1 3-Jan-15 100
Thanks
Chintan GandhiPosted Apr 15, 2025, 6:46 AM
Hi Ramco,
You can use below query to get your achivable result.
-- Opening Balance
SELECT
'Op Bal' AS Ac#,
NULL AS Date,
NULL AS Debit,
SUM(Credit) - SUM(Debit) AS Credit
FROM table1
WHERE Date < '2015-01-02'
AND Ac# = 1
UNION ALL
-- Transactions in date range
SELECT
Ac#,
Date,
Debit,
Credit
FROM table1
WHERE Date >= '2015-01-02'
AND Date <= '2015-01-03'
AND Ac# = 1
ORDER BY
CASE WHEN Date IS NULL THEN 0 ELSE 1 END,
Date
Jignesh KumarPosted Dec 29, 2024, 5:02 AM
In your Crystal Report, you need to include the formula I provided in my earlier response.
Ramco RamcoPosted Dec 28, 2024, 2:09 PM
Hi Jignesh
Iam not getting through S.P. Where i should place formula so that first Opening Balance gets displayed then Detailstransactions during the period should get displayed.
Thanks
Jignesh KumarPosted Dec 28, 2024, 7:08 AM
Hello Ramco,
If your store procedure return correct values then you need to display on crystal report then please use below one,
If the "Op Bal" row does not directly appear in the dataset, create a formula to calculate it within Crystal Reports: