problem getting totals in a query

M

Michael

I have asked this in reports, but now it is more of a query problem (I
think)

I have a query that pulls all the orders and order details. In each row I
have a orderdetailID and a product. I need to get the total weight of
esigenza for each product. I have the query below, but this gives me a list
of the product but not totals of the weights. I am sure this is not the most
effective way to make a list of all the products totals. The way I have done
it now, I must make a query for each product. Is there a better way?

Thank you

Michael



I currently have this sql in a query

SELECT [order details query].Esigenz, [order details query].Prodotto

FROM [order details query]

GROUP BY [order details query].Esigenz, [order details query].Prodotto

HAVING ((([order details query].Prodotto)="Latt.Verde")) OR ((([order
details query].Prodotto)="Latt.Verde (L)"));







This is what I would like

OrderDetailID product cases pallets casesperrow netwgt Esigenza

1 Cherries 88 5 8 125gr 440

2 Cherries 88 5 8 125gr 440

3 Apples 88 6 8 125gr 528

4 Cherries 88 4.5 10 125gr 495

Cherries total 1375 kg

Apple total 528 kG
 
M

Michael

I got it by using the below sql, but i have to make one query for each
product. Is there a better way?
Thank you
Michael


SELECT Sum([order details query].Esigenz) AS SumOfEsigenz, [order details
query].Prodotto
FROM [order details query]
GROUP BY [order details query].Prodotto
HAVING ((([order details query].Prodotto)="Rucola Selvatica" Or ([order
details query].Prodotto)="Rucola Selvatica (L)"));
 
M

Michael

got it

SELECT Sum([order details query].Esigenz) AS SumOfEsigenz, [order details
query].Prodotto
FROM [order details query]
GROUP BY [order details query].Prodotto;

Michael said:
I got it by using the below sql, but i have to make one query for each
product. Is there a better way?
Thank you
Michael


SELECT Sum([order details query].Esigenz) AS SumOfEsigenz, [order details
query].Prodotto
FROM [order details query]
GROUP BY [order details query].Prodotto
HAVING ((([order details query].Prodotto)="Rucola Selvatica" Or ([order
details query].Prodotto)="Rucola Selvatica (L)"));






Michael said:
I have asked this in reports, but now it is more of a query problem (I
think)

I have a query that pulls all the orders and order details. In each row I
have a orderdetailID and a product. I need to get the total weight of
esigenza for each product. I have the query below, but this gives me a
list of the product but not totals of the weights. I am sure this is not
the most effective way to make a list of all the products totals. The way
I have done it now, I must make a query for each product. Is there a
better way?

Thank you

Michael



I currently have this sql in a query

SELECT [order details query].Esigenz, [order details query].Prodotto

FROM [order details query]

GROUP BY [order details query].Esigenz, [order details query].Prodotto

HAVING ((([order details query].Prodotto)="Latt.Verde")) OR ((([order
details query].Prodotto)="Latt.Verde (L)"));







This is what I would like

OrderDetailID product cases pallets casesperrow netwgt Esigenza

1 Cherries 88 5 8 125gr 440

2 Cherries 88 5 8 125gr 440

3 Apples 88 6 8 125gr 528

4 Cherries 88 4.5 10 125gr 495

Cherries total 1375 kg

Apple total 528 kG
 

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