Bird
0
0

Consider this PostgreSQL code snippet inside a function:

medium📝 query result Q13 of 15
PostgreSQL - PL/pgSQL Fundamentals

Consider this PostgreSQL code snippet inside a function:

IF score >= 90 THEN
  result := 'A';
ELSIF score >= 80 THEN
  result := 'B';
ELSIF score >= 70 THEN
  result := 'C';
ELSE
  result := 'F';
END IF;

If score is 85, what will be the value of result after execution?

A'A'
B'F'
C'C'
D'B'
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate conditions in order for score = 85

    Check if 85 >= 90? No. Then check 85 >= 80? Yes.
  2. Step 2: Assign result based on first true condition

    Since 85 >= 80 is true, result is set to 'B'. Remaining conditions are skipped.
  3. Final Answer:

    'B' -> Option D
  4. Quick Check:

    85 >= 80 = true, so result = 'B' [OK]
Quick Trick: Check conditions top to bottom; first true sets the result [OK]
Common Mistakes:
  • Choosing 'A' because 85 is close to 90
  • Ignoring order of conditions
  • Assigning 'C' or 'F' incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes