4. Identify the error in this SQL query: SELECT CEIL(5.7 2) FROM dual;
medium
A. CEIL does not accept decimal numbers
B. CEIL requires two arguments
C. Missing comma between arguments
D. Syntax is correct
Solution
Step 1: Check CEIL function syntax
CEIL takes only one argument, a number, with no second argument.
Step 2: Analyze given query
The query has '5.7 2' without a comma, which is invalid syntax.
Final Answer:
Missing comma between arguments -> Option C
Quick Check:
CEIL needs one number, no extra arguments [OK]
Hint: Check commas between function arguments [OK]
Common Mistakes:
Adding extra arguments to CEIL
Forgetting commas between arguments
Assuming CEIL rounds decimals differently
5. You have a table prices with a column cost containing decimal values. You want to create a new column cost_rounded that rounds cost to the nearest integer but always rounds .5 up. Which SQL expression should you use?
hard
A. FLOOR(cost + 0.5)
B. CEIL(cost - 0.5)
C. ROUND(cost)
D. CEIL(cost)
Solution
Step 1: Understand rounding .5 up requirement
Standard ROUND rounds .5 up, but behavior can vary by SQL dialect.
Step 2: Analyze options
FLOOR(cost + 0.5) uses FLOOR(cost + 0.5), which shifts values so .5 rounds up correctly.
Step 3: Verify other options
ROUND(cost) may round .5 up but depends on implementation; B and D do not correctly round .5 up.
Final Answer:
FLOOR(cost + 0.5) -> Option A
Quick Check:
Use FLOOR(x + 0.5) to round .5 up reliably [OK]
Hint: Add 0.5 then FLOOR to round .5 up [OK]
Common Mistakes:
Assuming ROUND always rounds .5 up
Using CEIL directly without adjustment
Using FLOOR without adding 0.5
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.