Oracle SQL Oracle SQL Functions 2 — Questions and Answers
Question 1: Which Oracle SQL aggregate function returns the average of a column's values?
- MEAN
- SUM/COUNT
- AVG (Correct answer)
- MEDIAN
Correct answer: AVG
AVG calculates the arithmetic mean of non-NULL values in a column.
Question 2: What does the CONCAT function do in Oracle SQL?
- Splits a string into parts
- Joins two strings together (Correct answer)
- Finds the position of a substring
- Converts a number to a string
Correct answer: Joins two strings together
CONCAT(string1, string2) joins two strings end-to-end, equivalent to using the || operator in Oracle.
Question 3: Which Oracle SQL function returns the smallest integer greater than or equal to a number?
- FLOOR
- ROUND
- CEIL (Correct answer)
- TRUNC
Correct answer: CEIL
CEIL (ceiling) returns the smallest integer that is greater than or equal to the input number.
Question 4: What does TO_CHAR(SYSDATE, 'YYYY-MM-DD') return in Oracle SQL?
- The date as a DATE data type
- The current date formatted as a string like '2026-03-21' (Correct answer)
- The number of days since epoch
- An error because SYSDATE cannot be converted
Correct answer: The current date formatted as a string like '2026-03-21'
TO_CHAR converts a DATE to a VARCHAR2 string using the specified format mask, producing a readable date string.
Question 5: Which Oracle SQL function searches for a substring within a string and returns its position?
- SEARCH
- FIND
- INSTR (Correct answer)
- LOCATE
Correct answer: INSTR
INSTR(string, substring) returns the position of the first occurrence of substring within string, or 0 if not found.
Question 6: What does the DECODE function do in Oracle SQL?
- Decodes Base64 encoded strings
- Acts like a CASE expression, mapping values to results (Correct answer)
- Decrypts encrypted data
- Converts character encoding
Correct answer: Acts like a CASE expression, mapping values to results
DECODE(expr, search1, result1, ..., default) compares expr to each search value and returns the corresponding result, similar to CASE WHEN.
Which Oracle SQL aggregate function returns the average of a column's values?