home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 19,127 of 19,505   
   twenty-six@b-mint.net to Erland Sommarskog   
   Re: CASE issue   
   24 Nov 14 13:32:21   
   
   On 24/11/2014 11:26, Erland Sommarskog wrote:   
   > twenty-six@b-mint.net (twenty-six@b-mint.net) writes:   
   >> When I run this query I get lots of 'Unknown'  values, but I'm not sure   
   >> why.   
   >   
   > This happens because   
   >   
   >      CASE expr WHEN val1 THEN ....   
   >                WHEN val2 THEN ....   
   >   
   > is a shortcut for   
   >   
   >     CASE WHEN expr = val1 THEN   
   >          WHEN expr = val2 THEN   
   >   
   > and thus the expression gets evaluated multiple times and then it goes   
   > downhill from there.   
   >   
   > Set up a mapping table instead.   
   >   
   >   
   Ah I see, many thanks.    That would explain it nicely,  I really   
   thought I'd found a bug.   :-)   
      
   By mapping table you mean create a table,  insert 12 rows  with  1, Jan   
      2, Feb  etc.  then join with that?   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca