SQL Functions MCQs (Math, Text & Date Functions) | 25 Practice Questions with Answers | CBSE Class 12 Informatics Practices (IP)
Class 12 · Informatics Practices
SQL Functions MCQs (25 Questions)
Practice these multiple-choice questions to strengthen your understanding of SQL Math, Text, and Date Functions. Click Show Answer to reveal the correct answer and explanation.
Q1. Which SQL function returns the value of a number raised to a specified power?
A. ROUND()
B. POWER()
C. MOD()
D. SQRT()
Show Answer
Answer: B. POWER()
Explanation: The POWER() function returns a number raised to the specified exponent.
Q2. What is the output of POWER(2,3)?
A. 5
B. 6
C. 8
D. 9
Show Answer
Answer: C. 8
Explanation: 2³ = 8.
Q3. Which SQL function rounds a decimal number to the specified number of decimal places?
A. MOD()
B. POWER()
C. ROUND()
D. FORMAT()
Show Answer
Answer: C. ROUND()
Explanation: The ROUND() function rounds a number to the required decimal places.
Q4. What is the output of ROUND(45.678,1)?
A. 45.6
B. 45.7
C. 46.0
D. 45.68
Show Answer
Answer: B. 45.7
Explanation: The value is rounded to one decimal place.
Q5. Which SQL function returns the remainder after division?
A. MOD()
B. ROUND()
C. POWER()
D. DIV()
Show Answer
Answer: A. MOD()
Explanation: MOD() returns the remainder after dividing one number by another.
Q6. What is the output of MOD(17,5)?
A. 2
B. 3
C. 4
D. 5
Show Answer
Answer: A. 2
Explanation: 17 ÷ 5 leaves a remainder of 2.
Q7. Which SQL function converts text to uppercase?
A. LOWER()
B. UPPER()
C. MID()
D. LENGTH()
Show Answer
Answer: B. UPPER()
Explanation: UPPER() (or UCASE()) converts all characters to uppercase.
Q8. Which SQL function converts text to lowercase?
A. UPPER()
B. MID()
C. LOWER()
D. LEFT()
Show Answer
Answer: C. LOWER()
Explanation: LOWER() (or LCASE()) converts all characters to lowercase.
Q9. Which function returns the length of a string?
A. LEFT()
B. LENGTH()
C. RIGHT()
D. MID()
Show Answer
Answer: B. LENGTH()
Explanation: The LENGTH() function returns the number of characters in a string.
Q10. What is the output of LENGTH('COMPUTER')?
A. 7
B. 8
C. 9
D. 10
Show Answer
Answer: B. 8
Explanation: The word "COMPUTER" contains eight characters.
Q11. Which SQL function extracts characters from the beginning of a string?
A. RIGHT()
B. MID()
C. LEFT()
D. SUBSTR()
Show Answer
Answer: C. LEFT()
Explanation: LEFT() returns the specified number of characters from the left side of a string.
Q12. Which SQL function extracts characters from the end of a string?
A. LEFT()
B. RIGHT()
C. MID()
D. LENGTH()
Show Answer
Answer: B. RIGHT()
Explanation: RIGHT() returns characters from the right side of a string.
Q13. Which SQL function extracts part of a string starting from a specified position?
A. MID()
B. POWER()
C. ROUND()
D. NOW()
Show Answer
Answer: A. MID()
Explanation: MID(), SUBSTRING(), and SUBSTR() extract part of a string.
Q14. Which two SQL functions perform the same task of extracting part of a string?
A. POWER() and MOD()
B. SUBSTRING() and SUBSTR()
C. LEFT() and RIGHT()
D. NOW() and DATE()
Show Answer
Answer: B. SUBSTRING() and SUBSTR()
Explanation: Both functions extract a substring from a string.
Q15. Which SQL function returns the position of a substring within another string?
A. LENGTH()
B. MID()
C. INSTR()
D. TRIM()
Show Answer
Answer: C. INSTR()
Explanation: INSTR() returns the position of the first occurrence of a substring.
Q16. Which SQL function removes leading (left-side) spaces from a string?
A. RTRIM()
B. TRIM()
C. LTRIM()
D. LEFT()
Show Answer
Answer: C. LTRIM()
Explanation: The LTRIM() function removes spaces from the beginning (left side) of a string.
Q17. Which SQL function removes trailing (right-side) spaces from a string?
A. RTRIM()
B. LTRIM()
C. LEFT()
D. SUBSTR()
Show Answer
Answer: A. RTRIM()
Explanation: The RTRIM() function removes spaces from the end (right side) of a string.
Q18. Which SQL function removes both leading and trailing spaces?
A. LTRIM()
B. RTRIM()
C. TRIM()
D. MID()
Show Answer
Answer: C. TRIM()
Explanation: The TRIM() function removes spaces from both the beginning and the end of a string.
Q19. Which SQL function returns the current date and time?
A. DATE()
B. TODAY()
C. NOW()
D. CURRENT()
Show Answer
Answer: C. NOW()
Explanation: The NOW() function returns the current system date and time.
Q20. Which SQL function returns only the date part?
A. NOW()
B. DATE()
C. YEAR()
D. DAY()
Show Answer
Answer: B. DATE()
Explanation: The DATE() function extracts only the date portion from a date-time value.
Q21. Which SQL function returns the month number from a date?
A. MONTHNAME()
B. MONTH()
C. YEAR()
D. DAY()
Show Answer
Answer: B. MONTH()
Explanation: The MONTH() function returns the numeric month (1–12).
Q22. Which SQL function returns the name of the month?
A. MONTH()
B. DAYNAME()
C. MONTHNAME()
D. DATE()
Show Answer
Answer: C. MONTHNAME()
Explanation: The MONTHNAME() function returns the full name of the month, such as "January".
Q23. Which SQL function returns the year from a date?
A. MONTH()
B. YEAR()
C. DAY()
D. DATE()
Show Answer
Answer: B. YEAR()
Explanation: The YEAR() function extracts the year from a date.
Q24. Which pair of SQL functions returns the day number and the day name, respectively?
A. DAY() and DAYNAME()
B. MONTH() and MONTHNAME()
C. DATE() and NOW()
D. YEAR() and DATE()
Show Answer
Answer: A. DAY() and DAYNAME()
Explanation: DAY() returns the day of the month, while DAYNAME() returns the name of the day, such as "Monday".
Q25. Which statement best summarizes SQL Math, Text, and Date Functions?
A. Math functions perform numerical calculations.
B. Text functions manipulate string values.
C. Date functions extract or return date and time information.
D. All of these.
Show Answer
Answer: D. All of these.
Explanation: SQL provides specialized functions for numerical calculations, string manipulation, and handling date and time values, making queries more powerful and efficient.
Answer Key
| Q.No. | Answer | Q.No. | Answer | Q.No. | Answer |
|---|---|---|---|---|---|
| 1 | B | 11 | C | 21 | B |
| 2 | C | 12 | B | 22 | C |
| 3 | C | 13 | A | 23 | B |
| 4 | B | 14 | B | 24 | A |
| 5 | A | 15 | C | 25 | D |
| 6 | A | 16 | C | ||
| 7 | B | 17 | A | ||
| 8 | C | 18 | C | ||
| 9 | B | 19 | C | ||
| 10 | B | 20 | B |
Practice Tips
- Remember the Math Functions:
POWER(x, y)→ Returns x raised to the power y.ROUND(number, decimals)→ Rounds a number to the specified decimal places.MOD(a, b)→ Returns the remainder after division.
- Remember the Text Functions:
UPPER()/UCASE()→ Converts text to uppercase.LOWER()/LCASE()→ Converts text to lowercase.MID(),SUBSTRING(),SUBSTR()→ Extract part of a string.LENGTH()→ Returns the number of characters.LEFT()→ Extracts characters from the beginning.RIGHT()→ Extracts characters from the end.INSTR()→ Returns the position of a substring.LTRIM(),RTRIM(),TRIM()→ Remove spaces.
- Remember the Date Functions:
NOW()→ Current date and time.DATE()→ Extracts only the date.MONTH()→ Month number.MONTHNAME()→ Month name.YEAR()→ Year.DAY()→ Day of the month.DAYNAME()→ Name of the day.
- CBSE Tip: In competency-based questions, you are often given an SQL query and asked to identify its output or choose the correct function. Focus on understanding the purpose of each function and practice simple examples.