Decimal Alias values return as zero?

  • Thread starter Thread starter Jay
  • Start date Start date
J

Jay

Hi,

I'm fairly new to .adp's and have a stored procedure in which I have an
alias which performs a simple division calculation.

However, if the result is between 0 and 1 (i.e the two fields in the
calculation contain 500 & 700, so 500÷700 =0.71) my stored procedure
displays this as 0?

Can anyone advise how I get my alias field to display as decimal. Is there
some way to format the field in the SQL?

Any help greatly appreciated........Thanks, Jason
 
Add a decimal point to at least one operand:

Select (500 / 700), (500 / 700.0)
 
And convert to real or float if you want to have more decimal:

Select (500 / 700), (500 / 700.0), (500 / convert (real, 700)), (500 /
convert (float, 700))
 
Thanks for the suggestion, but I can't add a decimal point to any of the
two field being used in the calculation because these are fields on the
sql server which I can only refer to by field name.

Thanks......Jason
 
Then use the convert (or cast) function to convert your integer fields to
float or real types.
 
Back
Top