Reputation: 250
My Table is like
| Cat | Sub_Cat | Amt|
______________________
X | Y | 200
_______________________
X | Z | 1000
__________________________
X | Y | 300
__________________________
A | B | 600
Now i want to write a query where i can Show a summarized report which is grouped by category like this output
| Cat | Sub_Cat | Amt|
______________________
X | Y | 500
_______________________
X | Z | 1000
__________________________
A | B | 600
Kindly help
Upvotes: 1
Views: 58
Reputation: 4462
select t.cat, t.sub_cat, sum(t.amt) from table t
group by t.cat, t.sub_cat
Upvotes: 2
Reputation: 8090
Try this:
SELECT
Cat,
Sub_Cat,
SUM(Amt) as total
FROM
my_table
GROUP BY
Cat,
Sub_Cat
Upvotes: 2