MCQs on SQL Functions and Expressions | Data Manipulation

Topic 1: String Functions (UPPER, LOWER, CONCAT, etc.)

  1. Which SQL function is used to convert a string to uppercase?
    • A) UPPER
    • B) LOWER
    • C) CONCAT
    • D) TRIM
  2. The CONCAT function in SQL is used to:
    • A) Remove extra spaces from a string
    • B) Combine two or more strings into one
    • C) Change the case of a string
    • D) Split a string into an array
  3. Which function in SQL is used to convert a string to lowercase?
    • A) LOWER
    • B) UPPER
    • C) INITCAP
    • D) CONCAT
  4. To get the length of a string, which function would you use in SQL?
    • A) LENGTH
    • B) CHAR_LENGTH
    • C) SIZE
    • D) COUNT
  5. What does the TRIM function do in SQL?
    • A) Removes all spaces from a string
    • B) Removes leading and trailing spaces from a string
    • C) Concatenates strings
    • D) Converts a string to uppercase
  6. Which function is used to replace a substring with another substring in SQL?
    • A) REPLACE
    • B) SUBSTRING
    • C) CONCAT
    • D) POSITION
  7. Which SQL function is used to extract a substring from a string?
    • A) SUBSTRING
    • B) LEFT
    • C) RIGHT
    • D) SPLIT
  8. What does the INSTR function return in SQL?
    • A) The position of a substring in a string
    • B) The total length of a string
    • C) A substring of a string
    • D) The case of a string
  9. Which SQL function is used to remove trailing spaces from a string?
    • A) LTRIM
    • B) RTRIM
    • C) TRIM
    • D) LENGTH
  10. To find the position of a character or substring in a string, which function would you use?
    • A) POSITION
    • B) INSTR
    • C) LOCATE
    • D) FIND

Topic 2: Date and Time Functions (SYSDATE, TO_DATE, etc.)

  1. Which function in SQL returns the current system date and time?
    • A) CURRENT_DATE
    • B) GETDATE()
    • C) SYSDATE
    • D) NOW()
  2. To convert a string to a date in SQL, which function would you use?
    • A) TO_DATE
    • B) DATE_FORMAT
    • C) CAST
    • D) CONVERT
  3. Which function is used to get the current date in SQL?
    • A) CURRENT_DATE
    • B) GETDATE()
    • C) SYSDATE
    • D) NOW()
  4. How would you extract the year from a date in SQL?
    • A) YEAR()
    • B) EXTRACT(YEAR FROM date)
    • C) DATE_PART(‘year’, date)
    • D) TO_CHAR(date, ‘YYYY’)
  5. To add a specified interval to a date, which SQL function would you use?
    • A) DATE_ADD
    • B) ADD_INTERVAL
    • C) ADD_DATE
    • D) DATE_SUB
  6. Which function is used to calculate the difference between two dates in SQL?
    • A) DATEDIFF
    • B) DATE_SUB
    • C) DATE_DIFF
    • D) DAYS_BETWEEN
  7. What does the TO_DATE function do in SQL?
    • A) Converts a date to a string
    • B) Converts a string to a date
    • C) Adds a time interval to a date
    • D) Formats a date
  8. To get the current time in SQL, which function would you use?
    • A) SYSDATE
    • B) CURRENT_TIME
    • C) GETTIME()
    • D) TIME_NOW
  9. Which SQL function is used to extract the month from a date?
    • A) MONTH()
    • B) EXTRACT(MONTH FROM date)
    • C) DATE_PART(‘month’, date)
    • D) TO_CHAR(date, ‘MM’)
  10. What does the TO_CHAR function do when used with dates?
    • A) Converts a date to a string with a specified format
    • B) Converts a string to a date
    • C) Extracts the date portion from a string
    • D) Calculates the current date

Topic 3: Numeric Functions (ROUND, TRUNC, MOD, etc.)

  1. Which SQL function is used to round a number to a specified number of decimal places?
    • A) ROUND
    • B) TRUNC
    • C) CEIL
    • D) FLOOR
  2. The TRUNC function in SQL is used to:
    • A) Round a number
    • B) Remove the decimal part of a number
    • C) Get the square root of a number
    • D) Calculate the modulus of a number
  3. What is the purpose of the MOD function in SQL?
    • A) To calculate the square of a number
    • B) To get the remainder of a division operation
    • C) To round a number
    • D) To get the average of numbers
  4. Which function would you use to get the absolute value of a number in SQL?
    • A) ABS
    • B) ROUND
    • C) CEIL
    • D) SIGN
  5. To calculate the square root of a number in SQL, which function would you use?
    • A) SQUARE()
    • B) SQRT()
    • C) POWER()
    • D) EXP()
  6. Which function in SQL returns the ceiling of a number (the smallest integer greater than or equal to the number)?
    • A) CEIL
    • B) ROUND
    • C) FLOOR
    • D) SIGN
  7. To round a number up to the nearest integer, which SQL function is used?
    • A) CEILING
    • B) ROUND
    • C) FLOOR
    • D) MOD
  8. What does the SIGN function in SQL do?
    • A) Returns the sign of a number (positive, negative, or zero)
    • B) Rounds a number to the nearest integer
    • C) Calculates the square of a number
    • D) Calculates the square root of a number
  9. Which function is used to calculate the power of a number in SQL?
    • A) EXP()
    • B) POWER()
    • C) SQRT()
    • D) ABS()
  10. Which function in SQL is used to return the number of digits to the left of the decimal point in a number?
    • A) LENGTH
    • B) FLOOR
    • C) ROUND
    • D) DIGITS

Answers

QnoAnswer
1A) UPPER
2B) Combine two or more strings into one
3A) LOWER
4A) LENGTH
5B) Removes leading and trailing spaces from a string
6A) REPLACE
7A) SUBSTRING
8A) The position of a substring in a string
9B) RTRIM
10B) INSTR
11C) SYSDATE
12A) TO_DATE
13A) CURRENT_DATE
14B) EXTRACT(YEAR FROM date)
15A) DATE_ADD
16A) DATEDIFF
17B) Converts a string to a date
18B) CURRENT_TIME
19B) EXTRACT(MONTH FROM date)
20A) Converts a date to a string with a specified format
21A) ROUND
22B) Remove the decimal part of a number
23B) Get the remainder of a division operation
24A) ABS
25B) SQRT()
26A) CEIL
27A) CEILING
28A) Returns the sign of a number (positive, negative, or zero)
29B) POWER()
30B) FLOOR

Use a Blank Sheet, Note your Answers and Finally tally with our answer at last. Give Yourself Score.

X
error: Content is protected !!
Scroll to Top