Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to sum a field if others are the same

Status
Not open for further replies.

christheprogrammer

Programmer
Jul 10, 2000
258
0
0
CA
Ok I feel like an idiot. How do you do this simple thing -
Here is an example of the fields:

Field1 Field2 Field3 Weight
apple sweet red 2
apple sweet red 3
orange sour orange 1
orange sour orange 3
orange sweet orange 6

And I want this:

apple sweet red 5
orange sour orange 4
orange sweet orange 6

The last field is just a sum of the others with the same field values...
I used to write complex SQL statements but I can't even do this now - definately not like riding a bike.. frustrating as hell
Cheers

Later
 
sorry i erred -
the input should be:

apple sweet red 1
apple sweet green 2
etc

and the query should total the "sweet apples"..
and give:

apple sweet 3

Later
 
select field1,field2,count(*) from mytable group by field1,field2

Mike Pastore

Hats off to (Roy) Harper
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top