Vicky K
Vicky K

Reputation: 1

Total Count of each column

I have two columns:

Segments           consumers
Premium            15630
Low                5000
Premium             5
Family shopper     45600
Family Shopper       56

and I want to have a total result for each segment like:

Segments                   Consumers
Premium                     xxx
Low                         xxx
Family Shopper              xxx

Upvotes: 0

Views: 82

Answers (2)

luisvenezian
luisvenezian

Reputation: 501

SELECT Segments, SUM(Consumers) FROM Table GROUP BY Segments

Upvotes: 0

Mushroomator
Mushroomator

Reputation: 9178

select segments, SUM(consumers)
from your_table_name
group by segments; 

This will be the same for pretty much all database systems but you might wanna read the documentation on those clauses for your database system as they are quite fundamental. See PostgreSQL SUM.

Upvotes: 1

Related Questions