cozzymotto
cozzymotto

Reputation: 103

sum specific values in table postgres

So I am new to postgres and having some issues, this is my table: enter image description here

I would like a query to return the table in this format:

enter image description here

I would like the area to be distinct with the sum of all sales in area1 and for area2, any help is appreciated.

Upvotes: 0

Views: 120

Answers (1)

user18098820
user18098820

Reputation:

You need GROUP BY

SELECT
  Area,
  SUM(sales) AS "sales"
FROM myTable
GROUP BY area
ORDER BY area;

Upvotes: 1

Related Questions