CBSE Class 12 Informatics Practices Question 70 of 81

MySQL Functions — Question 21

Back to all questions
21
Question

Question 13

Write suitable SQL query for the following :

(i) Display 7 characters extracted from 7th left character onwards from the string 'INDIA SHINING'.

(ii) Display the position of occurrence of string 'COME' in the string 'WELCOME WORLD'.

(iii) Round off the value 23.78 to one decimal place.

(iv) Display the remainder of 100 divided by 9.

(v) Remove all the expected leading and trailing spaces from a column userid of the table 'USERS'.

Answer

(i)

SELECT SUBSTR('INDIA SHINING', 7, 7);
Output
+-------------------------------+
| SUBSTR('INDIA SHINING', 7, 7) |
+-------------------------------+
| SHINING                       |
+-------------------------------+

(ii)

SELECT INSTR('WELCOME WORLD', 'COME');
Output
+--------------------------------+
| INSTR('WELCOME WORLD', 'COME') |
+--------------------------------+
|                              4 |
+--------------------------------+

(iii)

SELECT ROUND(23.78, 1);
Output
+-----------------+
| ROUND(23.78, 1) |
+-----------------+
|            23.8 |
+-----------------+

(iv)

SELECT MOD(100, 9);
Output
+-------------+
| MOD(100, 9) |
+-------------+
|           1 |
+-------------+

(v)

SELECT TRIM(userid) FROM USERS;