0
ladyskydiver

SQL question

Recommended Posts

Ok...my brain is non-functional today - no smartass comments, Remi. :P

Using SQL, I need to get the left of a derived field. For example,

DerivedField ----------------> DesiredResult

39.74834738 ----------------> 39
9.44 ----------------> 9
137102837.223 --------------> 137102837

HELP!!!
Life is short! Break the rules! Forgive quickly! Kiss slowly! Love truly, Laugh uncontrollably. And never regret anything that made you smile.

Share this post


Link to post
Share on other sites
Only if you want it to perform the mathematical function. If she explicitly wants the left without any conversions (such as FLOOR(-123.45) returning -124 instead of -123) basically, it just depends what she considers the "correct" result.

Ladyskydiver, make sure you confirm which one is most appropriate for your expected data.

edit:
Quote

These are numbers, therefore not entirely correct to treat them as character strings.



Generally yep that's a good point.


Another Edit: Copied and pasted from the help file for ladyskydiver to help her make her decision:

FLOOR
Returns the largest integer less than or equal to the given numeric expression.

Syntax
FLOOR ( numeric_expression )

Arguments
numeric_expression

Is an expression of the exact numeric or approximate numeric data type category, except for the bit data type.

Return Types
Returns the same type as numeric_expression.

Examples
This example shows positive numeric, negative numeric, and currency values with the FLOOR function.

SELECT FLOOR(123.45), FLOOR(-123.45), FLOOR($123.45)

The result is the integer portion of the calculated value in the same data type as numeric_expression.

--------- --------- -----------
123 -124 123.0000

Blues,
Ian

ps: raise your hand if you've been bitten in the ass before thanks to Bankers Rounding! :)
Performance Designs Factory Team

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

0