QUERY HELP: Multiplying table values using query for export?

floridaboy2004

New Member
Joined
Nov 17, 2004
Messages
44
Hello all,

I hope that your holidays have been going well...Happy EARLY New Year! :)

I have a quick question:

I have a table called "PRODUCTS." In this table, there are 2 fields called "PRODUCT ID #" and "PURCHASE #."

I need to create a query that will 'read' the numerical value in the source table for each of the 2 fields listed above and MULTIPLY the value for each of the 2 fields for each record times 2 (e.g. 'double' the value in the field). The data source is giving me 1/2 of what the values SHOULD be and I need to have DOUBLED values from a query to then export to a TEXT file.

Thanks in advance for your specific and detailed help! :) Again, Happy Holidays! :)

Best regards,

FB2004
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Re: QUERY HELP: Multiplying table values using query for exp

if i'm reading this correctly try setting a column up in query as follows....hopefully this is what you are after...

ProductCalc: [Product ID #] * [Purchase #] * 2
 
Upvote 0
Re: QUERY HELP: Multiplying table values using query for exp

Thanks for the quick reply, but could you clarify further for me?

What if I already have the 2 query fields listed as follows (for the PRODUCTS table):

PNum: Format([PurchNum],"#")

P_ID: Format([ProductID],"#")

WHERE should I put the "*2" in each of these FIELD values?

e.g. could someone give me a written-out example of HOW it should appear in the Query Field Box?

These are 2 SEPARATE fields that I need to multiply times 2 (e.g. 2 distinct values, NOT the product of 2 fields, then times 2, etc.).

Thanks SO much for your help and quick reply!
 
Upvote 0
Re: QUERY HELP: Multiplying table values using query for exp

Hi,
put the following SQL-String into the sql-view of your query and replace [table1] with the name of your table.

SELECT [table1].[purchnum]*2 as Pnum, [table1].[productID]*2 as P_ID
FROM [table1]
 
Upvote 0
Re: QUERY HELP: Multiplying table values using query for exp

Try this...this should do it....

PNum: Format([PurchNum]*2,"#")
P_ID: Format([ProductID]*2,"#")
 
Upvote 0
Re: QUERY HELP: Multiplying table values using query for exp

Thanks for the quick reply, Tonnic, but what if I already have the 2 query fields listed as follows (for the PRODUCTS table):

PNum: Format([PurchNum],"#")

P_ID: Format([ProductID],"#")

Also, WHERE should I put the "*2" in each of these FIELD values?

I assume that the above 'formatting' issues would change the SQL query that you suggested...I also have OTHER fields that I need to query for the export but THESE 2 are the ONLY fields that need to each be multiplied times 2 (e.g. doubled).

Thanks a MILLION (+1) for all of your help! :)

-FB2004
 
Upvote 0
Re: QUERY HELP: Multiplying table values using query for exp

Try the way "thenooch" has suggested.
 
Upvote 0

Forum statistics

Threads
1,221,840
Messages
6,162,311
Members
451,759
Latest member
damav78

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top