KnowledgeBoat Logo

Informatics Practices

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'.

SQL Queries

5 Likes

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;

Answered By

3 Likes


Related Questions