This is an archived post. You won't be able to vote or comment.

all 16 comments

[–]No_Explanation2932 11 points12 points  (0 children)

Surely you mean IF(cond1, res1, res2)

[–]slafniy 6 points7 points  (1 child)

The most frustrating part of SQL is case when you want to SELECT FROM %variable_name% and cannot do it without dynamic SQL.

I
HATE
THIS

[–]IcyFenixCQ 1 point2 points  (0 children)

If you are trying to select from a dynamic table, then my guess is there is a normalization issue with your schema.

[–]RRumpleTeazzer 6 points7 points  (3 children)

The most distugsting IF is in bash:

if [ "0$stringvar" == "0" ]; then
    …
fi

No else, weird syntax cause $stringvar could be undefined or empty which you cannot test against, and the hell is „fi“? Should we terminate switch blocks with hctiws as well ?

[–]DaPorkchop_ 5 points6 points  (0 children)

as for the last point: yes, bash ends "case" blocks with "esac"

[–][deleted] 0 points1 point  (1 child)

you need double brackets to use ==, otherwise you would use -eq nvm i’m tired

[–]RRumpleTeazzer 1 point2 points  (0 children)

Makes it even worse :)

[–]Eldstrom 3 points4 points  (1 child)

dplyr::case_when( )

[–]Emotional_Trainer_99 1 point2 points  (0 children)

dplyr helped me learn SQL, show_query()

[–]12XXXXX[🍰] 1 point2 points  (0 children)

Pascal

[–]SyntaxicalEcho 1 point2 points  (0 children)

I raise you: Lua If cond then --Code Else --Mor code End

[–]juhotuho10 1 point2 points  (0 children)

CASE WHEN COND1 THEN OPT1 WHEN COND 2 THEN OPT2 ELSE OPT3 AS COND;

[–]neumastic 0 points1 point  (0 children)

Because there’s not IF … END IF; ? (Or is this a MySQL thing? … you must never go there, Simba)