I have one sql table (Payable) it has columns as
cID|stdId|Cet|Apr |May |Jun |Jul |Aug |Sep |Oct |Nov |Dec |Jan |Feb |Mar
1 | std1| 1 |100 | 100| 100|200 |200 |300 |400 |500 |500 |600 |700 |500
1 | std1| 2 |100 | 100| 100|200 |200 |300 |400 |500 |500 |600 |700 |500
another table (Receipt)
cID|stdId|Cet|Apr |May |Jun |Jul |Aug |Sep |Oct |Nov |Dec |Jan |Feb |Mar
1 | std1| 1 |100 | 100| 100| 0 |0 |0 |0 |0 |0 |0 |0 |0
1 | std1| 2 |50 | 50 | 50 | 0 |0 |0 |0 |0 |0 |0 |0 |0
my questions is how to write sql query to show report as
Quarter-I(Apr to Jun)
Particulars | Amount |
Cat1 | 300 |
Cat2 | 300 |
Total Due for Quarter-I | 600 |
Total Received Amount | 450 | this value comes from Receipt table
Fine | 0 |
Total Payable Amount | 150 | this amount should show in Quarter-II
Quarter-II (Jul-Sep)
Particulars | Amount |
Cat1 | 700 |
Cat2 | 700 |
Total Due for Quarter-II| 1400 |
Total Received Amount | 0 |
Last Quarter Pending | 150 |
Fine | 0 |
Total Payable Amount | 1550 |
Similarly for Quarter-III(Oct-Dec) and Quarter-IV (Jan - Mar)
someone please help!........
[edit]
code
tags changed to
pre
tags to preserve formatting.[/edit]
What I have tried:
......................................................