Click here to Skip to main content
15,946,342 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
sir,
In my Crystal Report i have done following report

AMOUNT        TAX%         TAXAMOUNT
--------------------------------------
1000          2             20
2000          5             100
3000          5             150
4000          2             80

now from above report i want to show sum of AMOUNT AND TAXAMOUNT as follows that is group by TAX %


TAX %       ON AMOUNT      TAX AMOUNT
--------------------------------------
2           5000            100
5           5000            250


Please help me
Thank you,
Posted
Updated 27-Aug-12 23:49pm
v3

1 solution

SQL
select Tax%, SUM(AMOUNT), SUM(TAXAMOUNT)
from Accounts
group by Tax%
order by Tax%
 
Share this answer
 
v2
Comments
Maciej Los 27-Aug-12 14:49pm    
Good answer, my 5!
Where is a ORDER BY Tax clause?
pramod.hegde 27-Aug-12 14:55pm    
The requirement was only for group by. :)
However you can do order by also.

select Tax%, SUM(AMOUNT), SUM(TAXAMOUNT)
from Accounts
group by Tax%
order by Tax%
Maciej Los 27-Aug-12 14:59pm    
You're right about requirements. ORDER BY is not necessary, but is more elegant ;)
pramod.hegde 27-Aug-12 15:01pm    
I have updated the query with 'order by' clause.
Maciej Los 27-Aug-12 15:04pm    
OK ;)

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