Informatics Practices
Write the SQL queries which will perform the following operations :
(i) To display the year from your Date of Admission which is '2023-05-15'.
(ii) To convert your email id 'ABC@XYZ.com' to lowercase.
(iii) To remove leading spaces from a string 'my country'.
(iv) To display current date.
(v) To display the value of 106.
Answer
(i)
SELECT YEAR('2023-05-15');
Output
+--------------------+
| YEAR('2023-05-15') |
+--------------------+
| 2023 |
+--------------------+
(ii)
SELECT LCASE('ABC@XYZ.com');
Output
+----------------------+
| LCASE('ABC@XYZ.com') |
+----------------------+
| abc@xyz.com |
+----------------------+
(iii)
SELECT LTRIM(' my country');
Output
+---------------------+
| LTRIM('my country') |
+---------------------+
| my country |
+---------------------+
(iv)
SELECT CURDATE();
Output
+------------+
| CURDATE() |
+------------+
| 2024-05-21 |
+------------+
(v)
SELECT POWER(10, 6);
Output
+--------------+
| POWER(10, 6) |
+--------------+
| 1000000 |
+--------------+
Related Questions
Perform the following question based on these tables :
table PAYDAY (contains one column only) CycleDate DATE table ADDRESS ( contains following eight columns) LastName VARCHAR(25), FirstName VARCHAR(25), Street VARCHAR(50), City VARCHAR(25) State CHAR(2), Zip NUMBER, Phone VARCHAR(12), Ext VARCHAR(5)
Write a query to show the city of user with first name as 'MARK'.
Show via query how many days remain until Christmas. Round fractional days up using the numeric function ROUND.
Write a query against the EMPL table to show the names of all employees concatenated with their jobtypes.
Write a query against the ADDRESS table to show the names (first name, last name) and phones of all persons concatenated in following form :
TinaSeth23456789 MoradK.22211890
Table ADDRESS ( contains following eight columns)
LastName VARCHAR(25), FirstName VARCHAR(25), Street VARCHAR(50), City VARCHAR(25) State CHAR(2), Zip NUMBER, Phone VARCHAR(12), Ext VARCHAR(5)