0

I am facing a common problem in which, I want to fetch only single value from a field that are duplicates values and also get their sum value respectively.

For Example:

enter image description here

I just want to get sum of "profit" of particular year with their year label.

2
  • 2
    sum and group by Commented Jun 9, 2017 at 9:29
  • select year, sum(profit) as totalprofit from tablename group by year Commented Jun 9, 2017 at 9:31

1 Answer 1

5

Use group by to get the desired result

SELECT
    year,
    sum(PROFIT) 
FROM
    YOURTABLE 
GROUP BY
    year
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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