CASE
torsten.strauss
Posts: 271 Silver 3
in SQL Prompt
Hi Redgate Team,
[code]
SELECT CASE
WHEN stp.rows = 0 THEN 1
WHEN stp.rows = 0 THEN 1
WHEN stp.rows > 0
AND stp.rows <= 500 THEN 501
WHEN stp.rows > 500
AND stp.rows <= 25000 THEN 500 + stp.rows * 0.2
WHEN @autostat_legacy_behavior = 0
AND stp.rows > 25000 THEN 500 + stp.rows * 0.2
WHEN @autostat_legacy_behavior = 1
AND stp.rows > 25000 THEN SQRT(1000 * stp.rows)
END AS t;
WHEN stp.rows = 0 THEN 1
WHEN stp.rows = 0 THEN 1
WHEN stp.rows > 0
AND stp.rows <= 500 THEN 501
WHEN stp.rows > 500
AND stp.rows <= 25000 THEN 500 + stp.rows * 0.2
WHEN @autostat_legacy_behavior = 0
AND stp.rows > 25000 THEN 500 + stp.rows * 0.2
WHEN @autostat_legacy_behavior = 1
AND stp.rows > 25000 THEN SQRT(1000 * stp.rows)
END AS t;
[/code]
I expected to see the and either on the same line if the maximum length is not reached or with an indention otherwise it is hard to read,
It seems that the AND statement in the CASE clause will follow the rules of the AND / OR in a WHERE condition which should not be the case.
Thanks for fixing it!
Thanks!
Torsten
Tagged:
Answers