Created
March 29, 2017 17:35
-
-
Save patrickemuller/26bba09d66bd093bdc953323a6ba1ede to your computer and use it in GitHub Desktop.
How to use Conditional-Functions inside SELECT with PGSQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT id, name, CASE | |
WHEN aasm_state = 10 AND imported = false THEN true | |
ELSE false | |
END | |
AS available | |
FROM businesses | |
LIMIT 5; | |
/* Line 2 is your conditional */ | |
/* NOTE: will be F or T depending on your conditional */ | |
/* | |
id | name | available | |
----+------------------+----------- | |
38 | Teste | f | |
62 | Dog Palace | t | |
71 | Pet Samary`s | f | |
68 | Hora do Pet | t | |
69 | Pet shop do Marx | f | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment