Monday , November 18 2024

PostgreSQL CASE Statements

In this article, you will learn how to use the PostgreSQL CASE conditional expression to form conditional queries.

The PostgreSQL CASE expression is the same as IF/ELSE statement in other programming languages.

General Usage:

Let’s make the following comments according to the name of the movie in the movies table and the lenght of the movie.

-If the lenght of the film is between 0 and 60 minutes, ‘The lenght of the film seems a bit short’.

-If the lenght of the film is between 60 and 120 minutes, ‘The lenght of the film is good’.

-If the movie is longer, ‘Movie lenght is too long’.

Let’s write our plgpsql command according to the above conditions.

Loading

About Faruk Erdem

Leave a Reply

Your email address will not be published. Required fields are marked *