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
Find the output of the following SQL Query :
SELECT ROUND(7658.345, 2);
Find the output of the following SQL Query :
SELECT MOD(ROUND (13.9, 0), 3);
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'.
Based on the SQL table CAR_SALES, write suitable queries for the following :
NUMBER SEGMENT FUEL QT1 QT2 1 Compact HatchBack Petrol 56000 70000 2 Compact HatchBack Diesel 34000 40000 3 MUV Petrol 33000 35000 4 MUV Diesel 14000 15000 5 SUV Petrol 27000 54000 6 SUV Diesel 18000 30000 7 Sedan Petrol 8000 10000 8 Sedan Diesel 1000 5000 (i) Display fuel wise average sales in the first quarter.
(ii) Display segment wise highest sales in the second quarter.
(iii) Display the records in the descending order of sales in the second quarter.