CBSERanker

Loading

Worksheet 24091101 Database Query using SQL

Worksheet 24091101 Database Query using SQL

MCQs :

  1. Which SQL function is used to raise a number to a power?
    • (A) ROUND()
    • (B) MOD()
    • (C) POWER()
    • (D) TRIM()
  2. What does the ROUND() function do in SQL?
    • (A) Rounds a number up
    • (B) Rounds a number to the nearest integer
    • (C) Truncates decimal places
    • (D) Converts a number to a string
  3. Which SQL function returns the uppercase version of a string?
    • (A) UPPER()
    • (B) LCASE()
    • (C) MOD()
    • (D) LENGTH()
  4. The function LENGTH() in SQL is used to:
    • (A) Return the position of a substring in a string
    • (B) Return the length of a string
    • (C) Trim spaces from both sides of a string
    • (D) Convert a string to lowercase
  5. Which SQL function is used to extract a portion of a string?
    • (A) MID()
    • (B) LENGTH()
    • (C) UPPER()
    • (D) TRIM()
  6. To get the current date and time in SQL, which function is used?
    • (A) DATE()
    • (B) NOW()
    • (C) MONTH()
    • (D) DAYNAME()
  7. What does the RTRIM() function do in SQL?
    • (A) Removes spaces from the right side of a string
    • (B) Removes spaces from the left side of a string
    • (C) Removes both leading and trailing spaces
    • (D) Converts a string to lowercase
  8. The function INSTR() is used for:
    • (A) Extracting a substring
    • (B) Finding the position of a substring within another string
    • (C) Converting text to uppercase
    • (D) Calculating the length of a string

Assertion-Reasoning

  1. Assertion (A): The TRIM() function in SQL removes spaces from both sides of a string.
    Reason (R): The TRIM() function only works on characters, not numbers.
    • (A) Both A and R are true, and R is the correct explanation of A.
    • (B) Both A and R are true, but R is not the correct explanation of A.
    • (C) A is true, but R is false.
    • (D) A is false, but R is true.
  2. Assertion (A): The DAYNAME() function in SQL returns the name of the day for a given date.
    Reason (R): The DAY() function returns the full name of the day, such as “Monday” or “Tuesday.”
    • (A) Both A and R are true, and R is the correct explanation of A.
    • (B) Both A and R are true, but R is not the correct explanation of A.
    • (C) A is true, but R is false.
    • (D) A is false, but R is true.

SQL Programming Questions:

  1. Write an SQL query to raise 2 to the power of 5.
  2. Write an SQL query to round the number 23.567 to 2 decimal places.
  3. Write an SQL query to return the uppercase version of the string ‘database’.
  4. Write an SQL query to find the length of the string ‘SQL Functions’.
  5. Write an SQL query to extract ‘Functions’ from the string ‘SQL Functions’.
  6. Write an SQL query to get the current date and time.
  7. Write an SQL query to remove trailing spaces from the string ‘ Hello World ‘.
  8. Write an SQL query to find the position of ‘com’ in the string ‘Welcome’.
  9. Write an SQL query to return the name of the month from the current date.
  10. Write an SQL query to return the day of the week for ‘2023-09-01’.

Leave a Reply

Your email address will not be published. Required fields are marked *