@Valentine Gogichashvili:
yes, i could have provide better example. the biggest difference is that within pl/pgsql case i can put pl/pgsql constructs. like variable assignment, loops, and anything else.

in sql case (which you showed) i cannot – i can simply choose which value to return to external expression (“return” in your case).