Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create info in new field based on sales information

Status
Not open for further replies.

redjim

Technical User
May 16, 2002
1
MX
I was trying to make a little update query that
would use some sales information to create a minimum in-stock quantity for shopassist. I don't use the % markup field, so I was
planning on putting the information there. This is the query I first made:

update invntry
set invntry."% MARKUP" =
(SELECT SUM(sales_d.Qty) QTY
FROM sales_d D, sales_h H, INVNTRY I
WHERE sales_d.Slip_Number = sales_h.Slip_Number AND I."DESCRIPTION" =
D."DESCRIPTION" AND ((sales_h."Date">='04/12/02')) and supplier = 'MAXIMA')
where supplier = 'MAXIMA'

The problem with this is that I have 3 items for this supplier:
Sales were as follows:
Item1 8
Item2 6
Item3 1

When I ran the above query, I get a value of 15 in the % markup field for
all three of the products. That is obviously wrong.

I tried the following query:

update invntry
set invntry."% MARKUP" =
(SELECT description, SUM(sales_d.Qty) QTY
FROM sales_d D, sales_h H, INVNTRY I
WHERE sales_d.Slip_Number = sales_h.Slip_Number AND I."DESCRIPTION" =
D."DESCRIPTION" AND ((sales_h."Date">='04/12/02')) and supplier = 'MAXIMA'
order by description)
where supplier = 'MAXIMA'

and I got a type mismatch error.
I assume that I got the following results of the query
Item1 8
Item2 6
Item3 1
and I couldn't put that into the % markupfield.

How can I go about making this query work so that I can put the sales per
item per "x number of days sales" into some field in the table???
Thanks for any help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top