Return a real value when calculating from integers

Return a real value when calculating from integers

Post by Chris Arca » Thu, 06 Feb 2003 12:27:30



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?

Thanx in Advance
Chris

 
 
 

Return a real value when calculating from integers

Post by Greg Obleshchu » Thu, 06 Feb 2003 12:33:02


Hi Chris,
You need to convert Edit_Frequency to a real

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

or in your example
 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?

> Thanx in Advance
> Chris


 
 
 

Return a real value when calculating from integers

Post by oj » Thu, 06 Feb 2003 12:36:21


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?

> Thanx in Advance
> Chris

 
 
 

Return a real value when calculating from integers

Post by Chris Arca » Sat, 08 Feb 2003 03:09:48


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

> or in your example
>  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?

> > Thanx in Advance
> > Chris

 
 
 

1. Integer columns return as real numbers

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

2. Stored procedure

3. Please help: Integer, float, real, value @$#%@!*(&

4. Blob Fields

5. Storing real *large* integer values - ideas?

6. Text Datatype

7. NON EMPTY returns all rows when calculated member always returns a value

8. Determine if DTC is running

9. returning an integer value from a plb?

10. Sum of real fields(Rounded at 2on decimal position) returns values with more decimal digits

11. Calculated Members return a false value

12. Real number treated as Integers?

13. Integer / Real, which data type to use