Assign value to another fieldname using CASE statement

  • Paul White NZ (3/25/2010)


    The Dixie Flatline (3/25/2010)


    Tell me you have a life outside SQL.

    (0 row(s) affected)

    SOM 😛

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • Paul White NZ (3/24/2010)


    STR has some interesting properties:

  • The numeric parameter is always converted to FLOAT(53) first
  • The output is always (fixed length) CHAR - the default is CHAR(10)
  • The default string output is left-padded with spaces if necessary
  • It uses the ROUND algorithm (round up) if rounding is required
  • The default CHAR(10) is not enough to hold all INTEGER values
  • ...

    The data type of the RESULT column in that example is VARCHAR(20) - from the ResponseComments column - since VARCHAR has a higher data type precedence than the CHAR(10) returned by STR.

    Paul

    Thank you for the detailed explanation! Point very well taken.

    Now that we know the downsides of either of the two options the answer regarding the method to use is a lot easier: "It depends" 😀 :w00t:



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • lmu92 (3/25/2010)


    Now that we know the downsides of either of the two options the answer regarding the method to use is a lot easier: "It depends" 😀 :w00t:

    As always* 😉


    *Not always - it depends

  • It depends on whether or not it depends? :w00t:

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • The Dixie Flatline (3/25/2010)


    It depends on whether or not it depends? :w00t:

    Yes and/or no. :hehe:



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • The Dixie Flatline (3/25/2010)


    It depends on whether or not it depends? :w00t:

    I think we both know the (recursive) answer to that.

Viewing 6 posts - 16 through 20 (of 20 total)

You must be logged in to reply to this topic. Login to reply