Q-1. Write an SQL query to fetch “FIRST_NAME” from the Worker table using the alias name <WORKER_NAME>.
ANS.
The required query is:
Select FIRST_NAME AS WORKER_NAME from Worker;
| WORKER_NAME |
|---|
| Monika |
| Niharika |
| Vishal |
| Amitabh |
| Vivek |
| Vipul |
| Satish |
Geetika
Q-2. Write an SQL query to fetch “FIRST_NAME” from the Worker table in upper case.ANS.The required query is:
Select upper(FIRST_NAME) from Worker; | upper(FIRST_NAME) |
|---|
| MONIKA | | NIHARIKA | | VISHAL | | AMITABH | | VIVEK | | VIPUL | | SATISH | | GEETIKA |
|
|---|
Q-3. Write an SQL query to fetch unique values of DEPARTMENT from the Worker table.Ans. The required query is: Select distinct DEPARTMENT from Worker; | DEPARTMENT |
|---|
| HR | | Admin | Account
Q-4. Write an SQL query to print the first three characters of FIRST_NAME from the Worker table.Ans. The required query is: Select substring(FIRST_NAME,1,3) from Worker; |
| substring(FIRST_NAME,1,3) |
|---|
| Mon | | Nih | | Vis | | Ami | | Viv | | Vip | | Sat | Gee
Q-5. Write an SQL query to find the position of the alphabet (‘a’) in the first name column ‘Amitabh’ from the Worker table.Ans. The required query is: Select FIRST_NAME, INSTR(FIRST_NAME, "a") from Worker where FIRST_NAME = 'Amitabh'; Notes. - The INSTR does a case-insensitive search.
|
| FIRST_NAME | INSTR(FIRST_NAME, "a") |
|---|
| Amitabh | 5 |
|
Comments
Post a Comment