KnowledgeBoat Logo

Informatics Practices

Write the SQL functions which will perform the following operations :

(i) To display the name of the month of the current date.

(ii) To remove spaces from the beginning and end of a string, "Panorama".

(iii) To display the name of the day e.g., Friday or Sunday from your date of birth, dob.

(iv) To display the starting position of your first name(fname) from your whole name (name).

(v) To compute the remainder of division between two numbers, n1 and n2.

SQL Queries

4 Likes

Answer

(i)

SELECT MONTHNAME(CURDATE());
Output
+----------------------+
| MONTHNAME(CURDATE()) |
+----------------------+
| May                  |
+----------------------+

(ii)

SELECT TRIM("  Panorama  ");
Output
+----------------------+
| TRIM("  Panorama  ") |
+----------------------+
| Panorama             |
+----------------------+

(iii)

SELECT DAYNAME('2000-07-22');
Output
+-----------------------+
| DAYNAME('2000-07-22') |
+-----------------------+
| Saturday              |
+-----------------------+

(iv)

SELECT INSTR('Gupta Ashwini', 'Ashwini') AS StartingPosition;
Output
+------------------+
| StartingPosition |
+------------------+
|                7 |
+------------------+

(v)

SELECT MOD(n1, n2);

Answered By

2 Likes


Related Questions