How do I sum 2 or 3 fields from a lookup fields in table?

S

sebastico

Hello All!

I have the table F1UTc
CodAutonumber (PK)
CodFarmer (FK)
CodSemester (FK)
CodUT (Lookup field)
Quantity (numeric)

The CodUTc (Lookup field) have 8 values

I cretaed the sql:
SELECT F1UTc.CodPer, F1UTc.CodFin, F1UTc.CodUTc, F1UTc.Cantidad
FROM F1UTc
WHERE (((F1UTc.CodPer)="11") AND ((F1UTc.CodUTc)="2"));

What I would like to do is sum the total of values 2 and 6 from the CodUT
c(Lookup field) per CodSmester and per CodFarmer

Please help
 
M

Michel Walsh

SELECT CodFarmer, CodSmester, SUM(quantity)
FROM f1utc
WHERE codPer IN( "2", "6")
GROUP BY CodFarmer, CodSmester




assuming codPer is a string. If an integer, change the WHERE clause to:

WHERE codPer IN(2, 6)



Hoping it may help,
Vanderghast, Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top