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

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
 
K

Klatuu

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)
 
L

ldiaz

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
 
K

Ken Sheridan

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
 
L

ldiaz

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
 
Top