0

I know there are enough posts here about the percentage growth but nothing helped me.

I have a table with this columns:

    Retailer country, retailer_type, 
     product_type, product, year, revenue, 
     quantity, gross_margin 

I have to find out to every single product how it developed over the years and how much it grows per percentage.

Can anyone help me? i can do that for every single product and year but its too much and I'm trying to write a query to do it all in one

SELECT product, year, SUM(revenue) AS sum_2012
FROM hallo
WHERE retailer_country LIKE 'United%States'
AND year = 2012
Aylin
  • 1
  • 2
  • 5
    Please **[edit]** your question (by clicking on the [edit] link below it) and add some [sample data](https://ozh.github.io/ascii-tables/) and the expected output based on that data. [Formatted text](https://meta.stackoverflow.com/a/251362) please, [no screen shots](http://meta.stackoverflow.com/questions/285551/why-may-i-not-upload-images-of-code-on-so-when-asking-a-question/285557#285557). ([edit] your question - do **not** post code or additional information in comments) –  Feb 20 '19 at 11:02
  • You need a GROUP BY! – jarlh Feb 20 '19 at 11:44

1 Answers1

0

You will need to add GROUP BY to your statement.

SELECT Country, year, SUM(Revenue) AS 'sumrev'
FROM hallo
GROUP BY [Country], [year]
Tomchi
  • 3
  • 2