Postgresql case when multiple conditions
- switch case in postgresql function
- postgresql date functions
- switch case postgresql
Postgresql custom function...
How to Use CASE in PostgreSQL
- How to Use the Statement in PostgreSQL
- General Example of the Statement in PostgreSQL
- PostgreSQL Statement With Aggregate Functions
This article shows how to use the statement in PostgreSQL.
How to Use the Statement in PostgreSQL
The statement is similar to the in the general programming language.
Postgresql functions
But in SQL, if you want to write , you might need .
In PostgreSQL, there’s built-in functionality to use the expressions.
For example, let’s say you have the following database.
If you want to create the table above, the SQL command is below.
After that, use a script to populate the table; you can use the command.
General Example of the Statement in PostgreSQL
For example, you’ve been asked to divide the accounts based on their height.
If the height is less than 140cm, it’s ; if it’s between 140 and 160, then and 160 or above will be marked as .
PostgreSQL’s general structure of expression is given below.
In the , we can use the usual condition with a combination of and .
So, the SQL command will be