Sql

Asked • 04/29/19

sql - sum columns from same table having multiple unique ids?

I would like to sum 3 columns from the same table based on three unique id. If id="1" sum(area1) If id="2" sum(area2) if id="3" sum(area3) Table data: id area1 area2 area3 1 10 2 10 1 1 10 10 2 1 10 10 3 1 10 10 3 10 2 10 Output should be: id1= 43 id2 = 21 id3 = 43 Select houseID, sum(area1), b.sum(area2), c.sum(area3) FROM table1, table1 b, table1 c WHERE table1.id="1" or b.id = "2" or c.id="3"

1 Expert Answer

By:

PETE C. answered • 06/01/19

Tutor
5.0 (283)

BS in Math with minor in English with 30+ Years of Teaching Experience

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.