how sum a column in the same query based in a criteria?

  • Thread starter Thread starter ldiaz
  • Start date Start date
L

ldiaz

I have query named: "qry_WOProduced" and shows datas like this,
but I would like a column to sum "QtyProd" by each "Work_OrderN" and show
them in the column "TotalProdbyWO", can you please help?

Work_OrderN QtyProd STD_Rate [TotalProdbyWO]
12545 10 STD-25 30
12545 20 STD-25 30
12548 12 STD-25 24
12548 12 STD-25 24
12545 10 STD-25 10

Thanks
LD
 
A simple totals query
Work_OrderN - Group By
QtyProd - GroupBy
STD_Rate - GroupBy
TotalProdbyWO - Sum - This would be a calculated field tha would be nothing
more that a repeatition of QtyProd (If I understand your request correctly)
 
that does not work because I'm using that query linked to a subform for data
entry..

could you please help please.
--
Lorenzo Díaz
Cad Technician


Klatuu said:
A simple totals query
Work_OrderN - Group By
QtyProd - GroupBy
STD_Rate - GroupBy
TotalProdbyWO - Sum - This would be a calculated field tha would be nothing
more that a repeatition of QtyProd (If I understand your request correctly)

ldiaz said:
I have query named: "qry_WOProduced" and shows datas like this,
but I would like a column to sum "QtyProd" by each "Work_OrderN" and show
them in the column "TotalProdbyWO", can you please help?

Work_OrderN QtyProd STD_Rate [TotalProdbyWO]
12545 10 STD-25 30
12545 20 STD-25 30
12548 12 STD-25 24
12548 12 STD-25 24
12545 10 STD-25 10

Thanks
LD
 
Lorenzo:

Surprising as it may seem, it is possible to refer to the same query in a
DSum function call in the query. In query design view put the following (all
as one line) in the 'field' row of a blank column:

TotalProdbyWO:DSum("QtyProd", "qry_WOProduced", "Work_OrderN = " &
[Work_OrderN])

That assumes Work_OrderN is a number data type, If its text data type use:

TotalProdbyWO:DSum("QtyProd", "qry_WOProduced", "Work_OrderN = """ &
[Work_OrderN] & """")

Ken Sheridan
Stafford, England

ldiaz said:
that does not work because I'm using that query linked to a subform for data
entry..

could you please help please.
--
Lorenzo Díaz
Cad Technician


Klatuu said:
A simple totals query
Work_OrderN - Group By
QtyProd - GroupBy
STD_Rate - GroupBy
TotalProdbyWO - Sum - This would be a calculated field tha would be nothing
more that a repeatition of QtyProd (If I understand your request correctly)

ldiaz said:
I have query named: "qry_WOProduced" and shows datas like this,
but I would like a column to sum "QtyProd" by each "Work_OrderN" and show
them in the column "TotalProdbyWO", can you please help?

Work_OrderN QtyProd STD_Rate [TotalProdbyWO]
12545 10 STD-25 30
12545 20 STD-25 30
12548 12 STD-25 24
12548 12 STD-25 24
12545 10 STD-25 10

Thanks
LD
 
that works fine..

Thanks Ken.
--
Lorenzo Díaz
Cad Technician


Ken Sheridan said:
Lorenzo:

Surprising as it may seem, it is possible to refer to the same query in a
DSum function call in the query. In query design view put the following (all
as one line) in the 'field' row of a blank column:

TotalProdbyWO:DSum("QtyProd", "qry_WOProduced", "Work_OrderN = " &
[Work_OrderN])

That assumes Work_OrderN is a number data type, If its text data type use:

TotalProdbyWO:DSum("QtyProd", "qry_WOProduced", "Work_OrderN = """ &
[Work_OrderN] & """")

Ken Sheridan
Stafford, England

ldiaz said:
that does not work because I'm using that query linked to a subform for data
entry..

could you please help please.
--
Lorenzo Díaz
Cad Technician


Klatuu said:
A simple totals query
Work_OrderN - Group By
QtyProd - GroupBy
STD_Rate - GroupBy
TotalProdbyWO - Sum - This would be a calculated field tha would be nothing
more that a repeatition of QtyProd (If I understand your request correctly)


I have query named: "qry_WOProduced" and shows datas like this,
but I would like a column to sum "QtyProd" by each "Work_OrderN" and show
them in the column "TotalProdbyWO", can you please help?

Work_OrderN QtyProd STD_Rate [TotalProdbyWO]
12545 10 STD-25 30
12545 20 STD-25 30
12548 12 STD-25 24
12548 12 STD-25 24
12545 10 STD-25 10

Thanks
LD
 

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

Back
Top