1

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

2 Answers 2

2

Try this:

SELECT
  Cat,
  Sub_Cat,
  SUM(Amt) as total
FROM
  my_table
GROUP BY
  Cat,
  Sub_Cat
Sign up to request clarification or add additional context in comments.

Comments

2
select t.cat, t.sub_cat, sum(t.amt) from table t
group by t.cat, t.sub_cat

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.