1

suppose I have this record

empcode      net       year     month
602256     3479.97     2014       1
602256     33125.98    2014       1
602256     5247.11     2014       2
602256     7698.39     2014       2
602256     2941.46     2013       3
602256     5515.57     2014       3
602256     5758.68     2014       3
602256     4966.89     2013       4
602256     4984.06     2013       4
602256     5951.63     2014       4
602256     19861.04    2014       4     

what i want to happen is that i want to sum the net with the same year and month hope you can help me thank you in advance.

2 Answers 2

1

You should use the GROUP BY clause:

SELECT SUM(net) FROM table GROUP BY [year],[month]
Sign up to request clarification or add additional context in comments.

Comments

0

Its very simple by Group By cluase. Also whatever you given in group by clause , you can define in select like below, which gives better idea for calculation.

SELECT year, month, SUM(net) FROM table GROUP BY [year],[month]

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.