Aueisbiejei3i939
Aueisbiejei3i939

Reputation: 101

SQL Query Calculate Total

So let's say I have data in my query like this:

Name: |  Cost:
Oliver     20
Oliver     3
Oliver     2
Sarah      100
Sarah      7

How would I go about merging the data for each person into one row and having a total cost?

Upvotes: 0

Views: 47

Answers (1)

ScaisEdge
ScaisEdge

Reputation: 133360

you can use group by and sum()

select name, sum(cost)
from your_table
group by  name 

Upvotes: 1

Related Questions