Raymond D'Anjou
3/27/2007 4:35:00 PM
SELECT Item_Code, Qty_on_Hand - Qty_Allocated AS 'Qty_Free'
"DG" <nothere@somewhere.com> wrote in message
news:OpluuQIcHHA.2120@TK2MSFTNGP03.phx.gbl...
>I am VERY new to SQL programming and don't know if this is the correct
>place for this post but here goes.
>
> I have a spreadsheet in excel that I use ODBC to pull data from an SQL
> database. I can do the basic stuff (select fields from a table and return
> them). Normally I return the data to the spreadsheet then put functions
> into the spreadsheet to do some basic calculations. I found some info on
> doing these types of functions within the SQL statement but can't find how
> to subtract two fields and return the difference.
>
> Example the record contains Item_Code, Qty_on_Hand, Qty_Allocated. Is
> there a way to return the difference between Qty_on_Hand and Qty_Allocated
> as Qty_Free?
>
> SELECT Item_Code, SUBTRACT(Qty_on_Hand, Qty_Allocated) AS 'Qty_Free' did
> not work. It says Subtract is not known.
>
> Any help would be great.
>
> DG
>