Problem in Consult

G

gatarossi

Dear all,

I have a table with this information:

code qtde vlrUnit
10 100 0,5
10 150 1,0
10 200 1,5

and I'm trying to do a consult to obtain this:

cde qtde vlrUnit
10 450 1,1111

but I don't known if I put total in my consult because access sum the
unit value...

Thanks a lot!!!

André.
 
W

Wolfgang Kais

Hello André.

André said:
Dear all.
I have a table with this information:

code qtde vlrUnit
10 100 0,5
10 150 1,0
10 200 1,5

and I'm trying to do a consult to obtain this:

cde qtde vlrUnit
10 450 1,1111

but I don't known if I put total in my consult because
access sum the unit value...

The code is used for grouping, qtde seems so be a simple sum:
qtde: sum(qtde)
and the vlrUnit seems to be a weighted average:
vlrUnit: sum(qtde*vlrUnit)/sum(qtde)

The sql will look like this:
SELECT code, Sum(qtde) AS s, Sum(qtde*vlrUnit)/Sum(qtde) AS v
FROM Table1 GROUP BY code;
 

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

Similar Threads

Medium Price 4
Consult with 10 bigger values 2
Criteria in Consult 2
Consult to Insert Data 4
Bring the 10 bigger values 1
Building Form 4
summing in a query or report 4
Building Form 3

Top