## Return a real value when calculating from integers

### Return a real value when calculating from integers

How do I return a real value from a calculation of 3 intergers. Below
is the sql staement I am trying to excute

UPDATE Shots SET Edit_Frequency = 120, Edited_Time =
(((Edited_Frame_Out-Edited_Frame_In)+1)/Edit_Frequency) WHERE Shot_Id
= 32667

Here are the listed values
Edited_Frame_Out=1284
Edited_Frame_In=686
Edit_Frequency=120

Edited_Time is defined as a Real data type of size 4 in my Table and
(Edited_Frame_Out & Edited_Frame_In & Edit_Frequency) are defined as
Int of size 4.

After running this Edited_Time equals 4 when I need it to equal
4.991667

How can I make this happen?

Chris

### Return a real value when calculating from integers

Hi Chris,
You need to convert Edit_Frequency to a real

select (((1284-686)+1)/convert(real,120))

UPDATE Shots SET Edit_Frequency = 120, Edited_Time =
(((Edited_Frame_Out-Edited_Frame_In)+1)/convert(real,Edit_Frequency)) WHERE
Shot_Id
= 32667

--
I hope this helps
regards
Greg O MCSD
Document any SQL server database
version 2.2, the best just got better
AGS SQL Scribe http://www.ag-software.com/ags_scribe_index.asp

Quote:> How do I return a real value from a calculation of 3 intergers. Below
> is the sql staement I am trying to excute

> UPDATE Shots SET Edit_Frequency = 120, Edited_Time =
> (((Edited_Frame_Out-Edited_Frame_In)+1)/Edit_Frequency) WHERE Shot_Id
> = 32667

> Here are the listed values
> Edited_Frame_Out=1284
> Edited_Frame_In=686
> Edit_Frequency=120

> Edited_Time is defined as a Real data type of size 4 in my Table and
> (Edited_Frame_Out & Edited_Frame_In & Edit_Frequency) are defined as
> Int of size 4.

> After running this Edited_Time equals 4 when I need it to equal
> 4.991667

> How can I make this happen?

> Chris

### Return a real value when calculating from integers

UPDATE Shots SET Edit_Frequency = 120, Edited_Time =
(((Edited_Frame_Out-Edited_Frame_In)+1.0)/Edit_Frequency) WHERE Shot_Id
= 32667

--
-oj
RAC v2.1 & QALite are now RELEASED!!!
http://www.rac4sql.net

Quote:> How do I return a real value from a calculation of 3 intergers. Below
> is the sql staement I am trying to excute

> UPDATE Shots SET Edit_Frequency = 120, Edited_Time =
> (((Edited_Frame_Out-Edited_Frame_In)+1)/Edit_Frequency) WHERE Shot_Id
> = 32667

> Here are the listed values
> Edited_Frame_Out=1284
> Edited_Frame_In=686
> Edit_Frequency=120

> Edited_Time is defined as a Real data type of size 4 in my Table and
> (Edited_Frame_Out & Edited_Frame_In & Edit_Frequency) are defined as
> Int of size 4.

> After running this Edited_Time equals 4 when I need it to equal
> 4.991667

> How can I make this happen?

> Chris

### Return a real value when calculating from integers

Thanx for the help Greg, it worked perfect!!!!

Chris

> Hi Chris,
> You need to convert Edit_Frequency to a real

> select (((1284-686)+1)/convert(real,120))

>  UPDATE Shots SET Edit_Frequency = 120, Edited_Time =
>  (((Edited_Frame_Out-Edited_Frame_In)+1)/convert(real,Edit_Frequency)) WHERE
> Shot_Id
>  = 32667

> --
> I hope this helps
> regards
> Greg O MCSD
> Document any SQL server database
> version 2.2, the best just got better
> AGS SQL Scribe http://www.ag-software.com/ags_scribe_index.asp

> > How do I return a real value from a calculation of 3 intergers. Below
> > is the sql staement I am trying to excute

> > UPDATE Shots SET Edit_Frequency = 120, Edited_Time =
> > (((Edited_Frame_Out-Edited_Frame_In)+1)/Edit_Frequency) WHERE Shot_Id
> > = 32667

> > Here are the listed values
> > Edited_Frame_Out=1284
> > Edited_Frame_In=686
> > Edit_Frequency=120

> > Edited_Time is defined as a Real data type of size 4 in my Table and
> > (Edited_Frame_Out & Edited_Frame_In & Edit_Frequency) are defined as
> > Int of size 4.

> > After running this Edited_Time equals 4 when I need it to equal
> > 4.991667

> > How can I make this happen?

> > Chris

I have to support an application that uses PASSTHRU with SQL Server
7.0.  The integer columns (datatype int4) return as decimal values.
This happens when I configure the ODBC datasource with the "use regional
settings" option enabled.

Is there any way to get these columns to return as integer values?

Andy Fry