sql - Need help coming up with a query -


For each name in my table, I want to add the amount that appears next to each name for each name.

The names of the columns are au_fname, au_lname, and qty

what this table looks like

  Johnson White 5 Marjorie Green 5 Cheryl Carson 5 Michael O'Leary 5 Dean Straight 5 Minder Smith 5 Abraham Bennett 5 N Engl 5 Burt Glinglesby 5 Charlene Loxley 5 Morningstar Green 5 Reginald Blocht-Hall 5 Ekicho Yokomoto 5 Ins Dell Castillo 5 Michael Defrance 5 Dirk Stringer 5 Starnes McFether 5 Livia Carcen 5 Sylvia Penty Le 5 Sheryl Hunter 5   

Repeat some names many times.

Actually you need a group by au_fname and au_lname, so to get your answer, SUM ( Qty). Below is how you will do it.

  SELECT au_fname, au_lname from sUM (qty) yourTableName GROUP by au_fname, au_lname    

Comments