Board Q&A · Class 12 Informatics Practices

MySQL Functions: Class 12 CBSE Previous-Year Questions with Answers

CBSE Question Papers →

43 questions from CBSE board, sample and compartment papers (2024–2027), 1 to 5 marks, each with a model answer. Questions on math functions (POWER, MOD, ROUND), text functions (UCASE, LCASE, MID, SUBSTR, LEFT, RIGHT, INSTR, LENGTH, TRIM), date functions (NOW, DATE, MONTH, MONTHNAME, YEAR, DAYNAME) and aggregate functions: predicting outputs and writing queries.

Showing 43 of 292 questions
Group

MySQL Functions

43 Questions
MySQL Functions· 1 Mark· Q4· 2024 Board Paper
What will be the output of the following query? SELECT POWER(2, MOD(17, 3));
  1. (A)(i) 8
  2. (B)(ii) 1
  3. (C)(iii) 0
  4. (D)(iv) 4
MySQL Functions· 1 Mark· Q9· 2024 Board Paper
What will be the output of the following query? SELECT SUBSTR("G20 2023 INDIA", 5, 4);
  1. (A)(i) G20 2
  2. (B)(ii) 2023
  3. (C)(iii) INDI
  4. (D)(iv) 023
MySQL Functions· 1 Mark· Q14· 2024 Board Paper
Which MySQL string function is used to extract a substring from a given string based on a specified starting position and length?
  1. (A)(i) SUBSTRING_INDEX()
  2. (B)(ii) LENGTH()
  3. (C)(iii) MID()
  4. (D)(iv) TRIM()
MySQL Functions· 2 Marks· Q21· 2024 Board Paper
What will be the output of the following SQL queries : (i) SELECT RIGHT("CHANDRAYAN3", 4); (ii) SELECT ROUND(76345.456, 2);
MySQL Functions· 3 Marks· Q26· 2024 Board Paper
(a) Consider the given table and write the following queries in MySQL: Table : Sports Sid | SName | Fees | DateofPlay | CoachID 1 | Karate | 1200 | 2024-08-24 | S1 2 | Football | 1800 | 2024-09-13 | S2 3 | Cricket | 1500 | 2024-06-14 | S3 4 | Lawn Tennis | 2500 | 2024-09-25 | S4 5 | Badminton | 1800 | 2024-10-20 | S5 (i) To display Sid and name of those sports which are to be played in the month of September. (ii) To display all Sports names in lower case. (iii) To display last two characters of all sports names whose fees is less than 1500. OR (b) Predict the output of the following queries based on the table Sports given above: (i) SELECT UCASE(TRIM(SName)) FROM Sports WHERE Sid = 5; (ii) SELECT LEFT(SName, 3) FROM Sports WHERE DateofPlay > '2024-09-13'; (iii) SELECT SUBSTR(CoachId, 1) FROM Sports WHERE SName = 'Cricket' OR Fees >= 2000;
MySQL Functions· 1 Mark· Q2· 2025 Board Paper
What will be the output of the following SQL command? SELECT MONTHNAME('2024-08-02');
  1. (A)08
  2. (B)02
  3. (C)February
  4. (D)August
MySQL Functions· 1 Mark· Q8· 2025 Board Paper
State whether the following statement is True or False: The MOD() function in SQL returns the quotient of division operation between two numbers.
MySQL Functions· 1 Mark· Q11· 2025 Board Paper
Which SQL function calculates a^b (a raised to the power b)?
  1. (A)MOD()
  2. (B)POWER()
  3. (C)RAISE()
  4. (D)ROUND()
MySQL Functions· 1 Mark· Q16· 2025 Board Paper
With respect to SQL, match the function given in column-II with categories given in column-I: I | II (i) Math function | (a) COUNT() (ii) Aggregate function | (b) ROUND() (iii) Date function | (c) RIGHT() (iv) Text function | (d) YEAR()
  1. (A)(i)-(c), (ii)-(d), (iii)-(a), (iv)-(b)
  2. (B)(i)-(b), (ii)-(a), (iii)-(d), (iv)-(c)
  3. (C)(i)-(d), (ii)-(b), (iii)-(a), (iv)-(c)
  4. (D)(i)-(b), (ii)-(c), (iii)-(d), (iv)-(a)
MySQL Functions· 1 Mark· Q21· 2025 Board Paper
Assertion (A): The ROUND() function in SQL can be used to round off a number to a specified number of decimal places. Reason (R): The ROUND() function is a string function that accepts character values as input and returns numerical values as output.
  1. (A)Both Assertion (A) and Reason (R) are True and Reason (R) is the correct explanation for Assertion (A).
  2. (B)Both Assertion (A) and Reason (R) are True and Reason (R) is not the correct explanation for Assertion (A).
  3. (C)Assertion (A) is True and Reason (R) is False.
  4. (D)Assertion (A) is False, but Reason (R) is True.
MySQL Functions· 2 Marks· Q24· 2025 Board Paper
Consider the string, "Informatics Practices". Write suitable SQL queries for the following: (i) To convert the entire string to uppercase. (ii) To display the total number of characters in the given string.
MySQL Functions· 5 Marks· Q37· 2025 Board Paper
(a) Write SQL query for the following: (i) To display sum total of all the values of the Score column, from STUDENTS table. (ii) To display the first five characters of the Name column from STUDENTS table. (iii) To display the values of Name column from the STUDENTS table, after removing the trailing spaces. (iv) To retrieve the lowest score from the Score column of GRADES table. (v) To increase the fee of all students by 100, in the STUDENTS table. (The name of the column is FEE) OR (b) Write SQL queries for the following: (i) To calculate the square of 15. (ii) To round the number 456.789 to the nearest integer. (iii) To display the position of first occurrence of 'com' in the string 'mycommercial.com'. (iv) To display the name of the day for the date '2024-11-07'. (v) To display the current date and time.
MySQL Functions· 1 Mark· Q9· 2026 Board Paper
What will be the result of the following SQL command? SELECT LENGTH ('Data Base'); (Note: There is a single space between the words Data and Base.)
  1. (A)7
  2. (B)8
  3. (C)9
  4. (D)Error
MySQL Functions· 1 Mark· Q17· 2026 Board Paper
State whether the following statement is True or False: The INSTR (string1, string2) function in SQL returns 0 if string2 is not present as a substring in string1.
MySQL Functions· 1 Mark· Q19· 2026 Board Paper
What will be the result of the following SQL command: SELECT ROUND(15.678, 2);
  1. (A)15.00
  2. (B)15.67
  3. (C)15.68
  4. (D)16.00
MySQL Functions· 2 Marks· Q26· 2026 Board Paper
Write SQL queries to perform the following: (I) Display the month (in numeric form) of the date '2026-01-01'. (II) Display only the year part from the date '2026-01-01'.
MySQL Functions· 4 Marks· Q34· 2026 Board Paper
(a) Write a suitable SQL query based on the Guest table: (I) Display last 3 characters of guest name in upper case. (II) Display the name of the guest along with the day name of check-in date. (III) Display the remainder when charges are divided by 1000. (IV) Extract and display three characters, starting from the second character, of each guest name. OR (b) Write the output of the following SQL Queries based on the ORDERS table: I. SELECT CUSTOMERNAME FROM ORDERS WHERE DISCOUNT IS NOT NULL; II. SELECT CUSTOMERNAME, DISCOUNT FROM ORDERS WHERE DISCOUNT BETWEEN 5 AND 10; III. SELECT MONTHNAME (ORDERDATE) FROM ORDERS WHERE ORDERDATE IS NOT NULL; IV. SELECT ORDERID, DAY (ORDERDATE) FROM ORDERS;
MySQL Functions· 5 Marks· Q37· 2026 Board Paper
(a) Write suitable SQL query for the following: I. Display only the date part from the date/time expression '2026-01-01 10:10:10'. II. Convert all customer names from Cust_Name column to lowercase in Customer table. III. Extract the first 4 characters from the City_Name column in Location table. IV. Display the name of the city from CITY column in EVENT table, after removing leading spaces. V. Find the average salary from Salary column in Employees table. OR (b) Write suitable SQL query for the following: I. To display the value of 17 squared. II. To display the day part of the dates in Hire_Date column. III. To display the maximum value of the Bill_Amount column. IV. To remove leading and trailing spaces from Location column. V. To display total salary from tot_sal column.
MySQL Functions· 1 Mark· Q2· 2025 Compartment Paper
What will be the output of the following SQL command? SELECT MOD (20,6);
  1. (A)-2
  2. (B)4
  3. (C)2
  4. (D)8
MySQL Functions· 1 Mark· Q8· 2025 Compartment Paper
What will be the output of the following SQL query? SELECT MID ('INCREDIBLE INDIA', 6,3);
  1. (A)EDI
  2. (B)RED
  3. (C)DIB
  4. (D)CREDIB
MySQL Functions· 2 Marks· Q24· 2025 Compartment Paper
Write SQL Queries to perform the following task: (i) Extract the leftmost 5 characters after removing the leading and trailing spaces from "DESIGN THINKING" (ii) Display the day name of the week when the National Space Day was celebrated first i.e., '23-08-2023'.
MySQL Functions· 5 Marks· Q37· 2025 Compartment Paper
(a) Write suitable SQL query for the following: (i) Display the minimum value in the Salary column from the EMPLOYEES table. (ii) Display the FirstName column values in lowercase from the EMPLOYEES table. (iii) Retrieve the DepartmentName column values in uppercase from the DEPARTMENTS table, where the DepartmentName has a length of 7 characters. (iv) Show the remainder when dividing each value in the Salary column by 1000 in the EMPLOYEES table. (v) Count the rows in the EMPLOYEES table where Salary is greater than 50000. (b) Write suitable SQL queries for the following: (i) Find the power of 5 raised to 3. (ii) Convert the string 'DATA ANALYSIS' to lowercase. (iii) Display the first 4 characters of the string 'Information'. (iv) Extract the year from the date '1995-11-15'. (v) Display the number of characters in the string 'Cyber Security'.
MySQL Functions· 1 Mark· Q4· 2024 Sample Paper
Predict the output of the following query: SELECT MOD (9,0);
  1. (A)i. 0
  2. (B)ii. NULL
  3. (C)iii. NaN
  4. (D)iv. 9
MySQL Functions· 1 Mark· Q5· 2024 Sample Paper
Which of the following SQL functions does not belong to the Math functions category? i. POWER() ii. ROUND() iii. LENGTH() iv. MOD()
  1. (A)i. POWER()
  2. (B)ii. ROUND()
  3. (C)iii. LENGTH()
  4. (D)iv. MOD()
MySQL Functions· 1 Mark· Q9· 2024 Sample Paper
Predict the output of the following query: SELECT LCASE (MONTHNAME ('2023-03-05'));
  1. (A)i. May
  2. (B)ii. March
  3. (C)iii. may
  4. (D)iv. march
MySQL Functions· 1 Mark· Q14· 2024 Sample Paper
In SQL, the equivalent of UCASE() is:
  1. (A)i. UPPERCASE ()
  2. (B)ii. CAPITALCASE()
  3. (C)iii. UPPER()
  4. (D)iv. TITLE ()
MySQL Functions· 2 Marks· Q21· 2024 Sample Paper
Consider the given SQL string: “12#All the Best!” Write suitable SQL queries for the following: i. Returns the position of the first occurrence of the substring “the” in the given string. ii. To extract last five characters from the string.
MySQL Functions· 4 Marks· Q31· 2024 Sample Paper
Preeti manages database in a blockchain start-up. For business purposes, she created a table named BLOCKCHAIN. Assist her by writing the following queries: TABLE: BLOCKCHAIN +----+----------+-------+--------+------------------+ | id | user | value | hash | transaction_date | +----+----------+-------+--------+------------------+ | 1 | Steve | 900 | ERTYU | 2020-09-19 | | 2 | Meesha | 145 | @345r | 2021-03-23 | | 3 | Nimisha | 567 | #wert5 | 2020-05-06 | | 4 | Pihu | 678 | %rtyu | 2022-07-13 | | 5 | Kopal | 768 | rrt4% | 2021-05-15 | | 7 | Palakshi | 534 | wer@3 | 2022-11-29 | +----+----------+-------+--------+------------------+ i. Write a query to display the year of oldest transaction. ii. Write a query to display the month of most recent transaction. iii. Write a query to display all the transactions done in the month of May. iv. Write a query to count total number of transactions in the year 2022.
MySQL Functions· 5 Marks· Q33· 2024 Sample Paper
Write suitable SQL queries for the following: i. To calculate the exponent for 3 raised to the power of 4. ii. To display current date and time. iii. To round off the value -34.4567 to 2 decimal place. iv. To remove all the probable leading and trailing spaces from the column userid of the table named user. v. To display the length of the string ‘FIFA World Cup’. OR Kabir has created following table named exam: +-------+---------+------------------+-------+ | RegNo | Name | Subject | Marks | +-------+---------+------------------+-------+ | 1 | Sanya | Computer Science | 98 | | 2 | Sanchay | IP | 100 | | 3 | Vinesh | CS | 90 | | 4 | Sneha | IP | 99 | | 5 | Akshita | IP | 100 | +-------+---------+------------------+-------+ Help him in writing SQL queries to the perform the following task: i. Insert a new record in the table having following values: [6,'Khushi','CS',85] ii. To change the value “IP” to “Informatics Practices” in subject column. iii. To remove the records of those students whose marks are less than 30 . iv. To add a new column Grade of suitable datatype. v. To display records of “Informatics Practices” subject.
MySQL Functions· 1 Mark· Q16· 2025 Sample Paper
Match the following SQL functions/clauses with their descriptions: SQL Function | Description P. | MAX() | 1. Find the position of a substring in a string. Q. | SUBSTRING() | 2. Returns the maximum value in a column. R. | INSTR() | 3. Sorts the data based on a column. S. | ORDER BY | 4. Extracts a portion of a string.
  1. (A)P-2, Q-4, R-3, S-1
  2. (B)P-2, Q-4, R-1, S-3
  3. (C)P-4, Q-3, R-2, S-1
  4. (D)P-4, Q-2, R-1, S-3
MySQL Functions· 2 Marks· Q24· 2025 Sample Paper
Consider the string: "Database Management System". Write suitable SQL queries for the following: I. To extract and display "Manage" from the string. II. Display the position of the first occurrence of "base" in the given string.
MySQL Functions· 4 Marks· Q34· 2025 Sample Paper
(A) Rahul, who works as a database designer, has developed a database for a bookshop. This database includes a table BOOK whose column (attribute) names are mentioned below: BCODE: Shows the unique code for each book. TITLE: Indicates the book's title. AUTHOR: Specifies the author's name. PRICE: Lists the cost of the book. Table: BOOK BCODE | TITLE | AUTHOR | PRICE B001 | MIDNIGHT'S CHILDREN | SALMAN RUSHDIE | 500 B002 | THE GOD OF SMALL THINGS | ARUNDHATI ROY | 450 B003 | A SUITABLE BOY | VIKRAM SETH | 600 B004 | THE WHITE TIGER | ARAVIND ADIGA | 399 B005 | TRAIN TO PAKISTAN | KHUSHWANT SINGH | 350 I. Write SQL query to display book titles in lowercase. II. Write SQL query to display the highest price among the books. III. Write SQL query to display the number of characters in each book title. IV. Write SQL query to display the Book Code and Price sorted by Price in descending order. OR (B) Dr. Kavita has created a database for a hospital's pharmacy. The database includes a table named MEDICINE whose column (attribute) names are mentioned below: MID: Shows the unique code for each medicine. MED_NAME: Specifies the medicine name. SUPP_CITY: Specifies the city where the supplier is located. STOCK: Indicates the quantity of medicine available. DEL_DATE: Specifies the date when the medicine was delivered. Table: MEDICINE MID | MED_NAME | SUPP_CITY | STOCK | DEL_DATE M01 | PARACETAMOL | MUMBAI | 200 | 2023-06-15 M02 | AMOXICILLIN | KOLKATA | 50 | 2023-03-21 M03 | COUGH SYRUP | BENGALURU | 120 | 2023-02-10 M04 | INSULIN | CHENNAI | 135 | 2023-01-25 M05 | IBUPROFEN | AHMEDABAD | 30 | 2023-04-05 Write the output of the following SQL Queries. I. Select LENGTH(MED_NAME) from MEDICINE where STOCK > 100; II. Select MED_NAME from MEDICINE where month(DEL_DATE) = 4; III. Select MED_NAME from MEDICINE where STOCK between 120 and 200; IV. Select max(DEL_DATE) from MEDICINE;
MySQL Functions· 1 Mark· Q2· 2026 Sample Paper
What will be the result of the following SQL query? SELECT MOD(5, 6);
  1. (A)3
  2. (B)5
  3. (C)6
  4. (D)0
MySQL Functions· 1 Mark· Q6· 2026 Sample Paper
What is the purpose of the ROUND(num, 0) in SQL, assuming num is a number with a fractional part?
  1. (A)Rounds the number to the nearest integer
  2. (B)Always rounds the number up
  3. (C)Leaves the number unchanged
  4. (D)Always rounds the number down
MySQL Functions· 1 Mark· Q17· 2026 Sample Paper
What is the use of the INSTR() function in SQL?
  1. (A)To replace characters in a string
  2. (B)To find the length of a string
  3. (C)To find the position of a substring in a string
  4. (D)To extract characters from a string
MySQL Functions· 2 Marks· Q26· 2026 Sample Paper
Write SQL queries to perform the following: I. Display the name of the day (e.g., Monday, Tuesday) for the date '2026-01-01'. II. Find and display the position of the substring "India" in the string "Incredible India"
MySQL Functions· 4 Marks· Q34· 2026 Sample Paper
(A) Raghav, who works as a database designer, has created a table Student as shown below: Table: Student StudentID | Name | City | Marks | Admission_Date 101 | Aarav Sharma | Delhi | 85 | 2022-04-01 102 | Priya Iyer | Mumbai | 78 | 2021-05-15 103 | Rohan Verma | Bangalore | 92 | 2020-06-10 104 | Simran Patel | Delhi | 88 | 2022-03-20 105 | Karan Yadav | Mumbai | 75 | 2021-08-05 Write suitable SQL query for the following. I. Show the Name and City of the students, both in uppercase, sorted alphabetically by Name. II. Display the Student ID along with the name of the month in which the student was admitted to the school. III. Calculate and display the average marks obtained by students. IV. Show the names of the cities and the number of students residing in the city. OR (B) Consider the following table and write the output of the following SQL Queries. Table: Student StudentID | Name | DateofBirth | Marks | City 301 | Aryan | 15-03-2005 | 88 | Delhi 302 | Ayesha | NULL | 90 | NULL 304 | Aditi | NULL | 85 | Pune 305 | Rajesh | 11-01-2006 | 72 | NULL 306 | Maria | 29-04-2005 | 95 | Chennai Write the output of the following SQL Queries. I. SELECT Name, LENGTH(Name) FROM Student WHERE StudentID < 303; II. SELECT lower(Name) FROM Student WHERE MONTH(DateofBirth)= 3; III. SELECT AVG(Marks) FROM Student; IV. SELECT Name, Marks FROM Student WHERE Marks BETWEEN 90 AND 100;
MySQL Functions· 5 Marks· Q37· 2026 Sample Paper
(A) Write suitable SQL query for the following: I. To extract the first five characters from the product_code column in the Products table. II. To display the total number of orders from Order_Id column in the Orders table. III. To display the year of the order dates from the order_date column in the Orders table. IV. To display the Address column from the Customers table after removing leading and trailing spaces V. To display the current date. OR (B) Write suitable SQL query for the following: I. To display the total number of characters in the string DatabaseSystems. II. Find the position of the first occurrence of the letter 'a' in the Product_Name column of the Products table. III. Calculate the square of the Amount for each transaction in the Tran_Amount column of the Transactions table. IV. To display the average salary from the Salaries column in the Employees table. V. Display the total sum of the Salary from the Salary column in the Employees table.
MySQL Functions· 1 Mark· Q2· 2027 Sample Paper
Ravi needs to find the total number of characters in the StudentName column. Which SQL function should he use?
  1. (A)COUNT()
  2. (B)SIZE()
  3. (C)LENGTH()
  4. (D)TOTAL()
MySQL Functions· 1 Mark· Q14· 2027 Sample Paper
Which SQL function is used to extract a specific number of characters from a string starting from a given position?
  1. (A)LEFT()
  2. (B)RIGHT()
  3. (C)LENGTH()
  4. (D)MID()
MySQL Functions· 2 Marks· Q26· 2027 Sample Paper
Write SQL queries for the following requirements: (i) Display the last 3 characters of the attribute Ename from the EMPLOYEE table. (ii) Find the position of the substring 'ma' in the string 'Informatics'.
MySQL Functions· 3 Marks· Q31· 2027 Sample Paper
Consider the table HOSPITAL, which contains the following columns: Column Name | Remark PNo | Patient Number PName | Patient Name Dept | Department DOA | Date of Admission Table: HOSPITAL PNo | PName | Dept | DOA 101 | Ravi Kumar | Cardiology | 2024-05-12 102 | Anita Sharma | Neurology | 2025-06-01 103 | Mohan Das | Cardiology | 2023-05-18 104 | Seema Verma | Orthopedics | 2022-04-22 105 | Rahul Singh | Cardiology | 2025-03-30 Write SQL queries to perform the following tasks: (i) Display the names of all patients in the Cardiology department in lowercase. (ii) Display each patient's number along with the day name of the week on which they were admitted. (iii) Display the patient names arranged in alphabetical order.
MySQL Functions· 3 Marks· Q32· 2027 Sample Paper
(A) Consider a table named STUDENT containing the following data: ID | Name | DOB 1 | Aman | 2005-08-15 2 | Vinod | 2006-01-26 3 | Saurabh | 2004-01-01 Write the output of the following SQL queries: (i) SELECT UPPER(Name), LENGTH(Name) FROM STUDENT WHERE ID = 2; (ii) SELECT DAY(DOB), YEAR(DOB) FROM STUDENT WHERE ID = 3; (iii) SELECT RIGHT(Name, 3) FROM STUDENT WHERE ID = 1; OR (B) Write the output of the following SQL queries: (i) SELECT POWER(MOD(13, 5), 2); (ii) SELECT UCASE(MID("Digital India", 9, 5)); (iii) SELECT LENGTH(TRIM(" Informatics "));