**Prerequisite **– PL/SQL introduction

In PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations.

Given three numbers and the task is to find greatest among them.

**Examples:**

Input: a = 46, b = 67, c = 21 Output: 67 Input: a = 9887, b = 4554, c = 212 Output: 9887

**Approach** is to consider the first number and compare it with other two numbers. Similarly, check with second and third.

Below is the required implementation:

`--To find the greatest number ` `-- among given three numbers ` `DECLARE` ` ` `--a assigning with 46 ` ` ` `a NUMBER := 46; ` ` ` `--b assigning with 67 ` ` ` `b NUMBER := 67; ` ` ` `--c assigning with 21 ` ` ` `c NUMBER := 21; ` `BEGIN` ` ` `--block start ` ` ` `--If condition satrt ` ` ` `IF a > b ` ` ` `AND` `a > c ` `THEN` ` ` `--if a is greater then print a ` ` ` `dbms_output.Put_line(` `'Greatest number is '` ` ` `||a); ` ` ` `ELSIF b > a ` ` ` `AND` `b > c ` `THEN` ` ` `--if b is greater then print b ` ` ` `dbms_output.Put_line(` `'Greatest number is '` ` ` `||b); ` ` ` `ELSE` ` ` `--if c is greater then print c ` ` ` `dbms_output.Put_line(` `'Greatest number is '` ` ` `||c); ` ` ` `END` `IF; ` `--end if condition ` `END` `; ` `--End program ` |

*chevron_right*

*filter_none*

**Output**

Greatest number is 67

## Recommended Posts:

- PLSQL | GREATEST Function
- PLSQL | LOG Function
- PLSQL | INSTR Function
- PLSQL | INSTRB Function
- PLSQL | LENGTH2 Function
- Difference between SQL and PLSQL
- PLSQL | SOUNDEX Function
- PLSQL | ASCII Function
- PLSQL | CONCAT Function
- PLSQL | COMPOSE Function
- PLSQL | CHR Function
- PLSQL | ASCIISTR Function
- PLSQL | CONVERT Function
- PLSQL : || Operator
- PLSQL | DECOMPOSE Function
- PLSQL | DUMP Function
- PLSQL | INITCAP Function
- PLSQL | LENGTHC Function
- PLSQL | LENGTHB Function
- PLSQL | LENGTH4 Function

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.