Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #1847

Re: CASE issue

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Lennart Jonsson <erik.lennart.jonsson@gmail.com>
Newsgroups comp.databases.ms-sqlserver
Subject Re: CASE issue
Date Mon, 24 Nov 2014 17:18:43 +0100
Organization A noiseless patient Spider
Lines 31
Message-ID <m4vlom$q0c$1@dont-email.me> (permalink)
References <547306f8$0$41749$c3e8da3$5d8fb80f@news.astraweb.com> <XnsA3EF7E8B63B6CYazorman@127.0.0.1>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Mon, 24 Nov 2014 16:18:31 +0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="7e2da11d2f2fa04799963f04fc962890"; logging-data="26636"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+TXaHlU8zntzcw2TybfhCh"
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.0
In-Reply-To <XnsA3EF7E8B63B6CYazorman@127.0.0.1>
Cancel-Lock sha1:GXaaPkxEHb/nCZZ9FOa4MssmCm8=
X-TagToolbar-Keys D20141124171842984
Xref csiph.com comp.databases.ms-sqlserver:1847

Show key headers only | View raw


On 11/24/2014 12:26 PM, 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.
>

I think (don't have time to look it up now) the SQL-standard says that 
the result of the CASE statement is the first condition that evaluates 
to true. From your answer I get the impression that this is not true for 
SQL-server, correct?

Surely only one value is returned, but is it indeterministic which one?


/Lennart

[...]

Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

CASE issue "twenty-six@b-mint.net" <twenty-six@b-mint.net> - 2014-11-24 10:22 +0000
  Re: CASE issue Erland Sommarskog <esquel@sommarskog.se> - 2014-11-24 11:26 +0000
    Re: CASE issue bradbury9 <ray.bradbury9@gmail.com> - 2014-11-24 04:16 -0800
      Re: CASE issue Erland Sommarskog <esquel@sommarskog.se> - 2014-11-24 14:28 +0000
        Re: CASE issue Erland Sommarskog <esquel@sommarskog.se> - 2014-11-28 22:47 +0100
          Re: CASE issue Jim <jgeissman@socal.rr.com> - 2014-11-28 17:19 -0800
    Re: CASE issue "twenty-six@b-mint.net" <twenty-six@b-mint.net> - 2014-11-24 13:32 +0000
      Re: CASE issue Erland Sommarskog <esquel@sommarskog.se> - 2014-11-24 14:25 +0000
        Re: CASE issue "twenty-six@b-mint.net" <twenty-six@b-mint.net> - 2014-11-24 16:06 +0000
    Re: CASE issue Lennart Jonsson <erik.lennart.jonsson@gmail.com> - 2014-11-24 17:18 +0100
      Re: CASE issue Erland Sommarskog <esquel@sommarskog.se> - 2014-11-24 23:37 +0100
        Re: CASE issue Lennart Jonsson <erik.lennart.jonsson@gmail.com> - 2014-11-25 06:25 +0100
          Re: CASE issue Jim <jgeissman@socal.rr.com> - 2014-11-28 16:07 -0800
            Re: CASE issue Erland Sommarskog <esquel@sommarskog.se> - 2014-11-29 10:43 +0100

csiph-web