Mixing CEIL and FLOOR results for negative numbers
Assuming ROUND always truncates
Forgetting ABS returns positive
4. Identify the error in this PostgreSQL query: SELECT ROUND(5.678, '1');
medium
A. ROUND requires only one argument
B. The second argument should be an integer, not a string
C. Missing FROM clause in the query
D. ROUND cannot be used with decimal numbers
Solution
Step 1: Check ROUND function arguments
ROUND expects the second argument to be an integer specifying decimal places, not a string.
Step 2: Validate other options
ROUND works with decimals, FROM clause is optional in SELECT without tables, and ROUND can take two arguments.
Final Answer:
The second argument should be an integer, not a string -> Option B
Quick Check:
ROUND(5.678, 1) is correct, ROUND(5.678, '1') causes error [OK]
Hint: Use integer for decimals, not quoted strings [OK]
Common Mistakes:
Passing decimals as quoted strings
Thinking FROM is mandatory for simple SELECT
Assuming ROUND only takes one argument
5. You want to calculate the total price after applying a 7.5% tax on a price of 123.4567 and round the result to 2 decimal places. Which PostgreSQL expression correctly does this?
hard
A. ROUND(123.4567 * 1.075, 2)
B. CEIL(123.4567 * 1.075, 2)
C. FLOOR(123.4567 * 1.075, 2)
D. ABS(123.4567 * 1.075, 2)
Solution
Step 1: Calculate price with tax
Multiply price by 1.075 (100% + 7.5%) to get total price including tax.
Step 2: Round to 2 decimal places
Use ROUND function with second argument 2 to round to two decimals.
Step 3: Check other functions
CEIL and FLOOR do not accept decimals argument, ABS is for absolute value, so they are incorrect here.
Final Answer:
ROUND(123.4567 * 1.075, 2) -> Option A
Quick Check:
ROUND(123.4567 * 1.075, 2) = 132.72 [OK]
Hint: Use ROUND for decimals, CEIL/FLOOR only for integers [OK]
Common Mistakes:
Using CEIL or FLOOR with decimal places argument
Using ABS instead of ROUND for rounding
Forgetting to multiply by 1.075 for tax
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.