Database System: Task 1
Database System: Task 1
TASK 1
Display the date of your coming lab which will be on next Thursday. Don’t use any date in
query.
Query:
TASK 2
Find position of ‘a’ in the names of all employees and print it with names.
Output will be like (SMITH0 ,WARD2).
QUERY:
SELECT ENAME ,CONCAT(ENAME, INSTR(ENAME, 'A')) AS "POSITION OF A" FROM EMP
TASK 3
TASK 4
Print a column name as “employees with my roll no” (print your own roll no.), in second column
print the length of this string.
Sample output
(SMITH’s roll no is BITF9a123)
QUERY:
SELECT ENAME ||'''s roll no is BITF19A036' AS "EMPLOYEES WITH ROLL NO",
LENGTH(ENAME ||'''s roll no is BITF19A036') FROM EMP;
TASK 5
Display salary, commission and total salary (salary + commission) in the format of *****20000.
QUERY:
SELECT SAL, COMM, LPAD(SAL+ NVL(COMM,0), 10, '*') AS "TOTAL SALARY" FROM EMP;
TASK 6
Print no. of weeks of all employees when he joined the company from today
QUERY:
SELECT ENAME, HIREDATE, SYSDATE AS "TODAY DATE",
TRUNC((SYSDATE - HIREDATE)/7) AS "WEEKS EMPLOYED" FROM EMP;
SCREEN SHOT:
TASK 7
Add 30 days in hire date of each employee and display both dates
QUERY:
SELECT HIREDATE, (HIREDATE + 30) FROM EMP;
TASK 8
TASK 9
Use a number function to get first date of current year and month.
QUERY:
SELECT TRUNC(SYSDATE, 'MONTH') AS "FIRST DATE" FROM DUAL;
SCRENNSHOT:
TASK 11
In the string BITF19AXXX, change XXX with your roll number as BITF19A001.
QUERY:
TASK 13
Display data of all the employees where last three characters of job is man.
QUERY:
TASK 14
TASK 16
Display hiredate and hiredate – X. (X = digit in your roll no (e.g BITF19A050 X=50)). And display
both dates as full names of day,month and year.
QUERY:
SELECT TO_CHAR(HIREDATE, 'DAY, DD MONTH, YYYY') AS "HIRE DATE",
TO_CHAR(HIREDATE - (SUBSTR ('BITF19A036', -3)), 'DAY, DD MONTH, YYYY') AS "NEW DATE"
FROM EMP;
TASK 17
Print names and “modified names” (put B instead of L in each name) in lower case.
QUERY:
TASK 18
Display name and hire date of every employee in the format of “ Wednesday, 17 December , 1980” and label
that column as Joining Date and also display current date in same format in 3 rd column.
QUERY:
SELECT ENAME,
FROM EMP;
TASK 19
Your name in a column starting ending with X no of ‘#’. (use padding) (X = digit in your roll no (e.g X=20))
Sample Output
X=5
SMITH arslan#####
ALLEN arslan#####
WARD arslan#####
QUERY:
SELECT ENAME,
FROM EMP;
TASK 20
Add 3600 minutes in hire date of each employee and display both dates
QUERY:
SELECT HIREDATE,
HIREDATE + 2.5 AS "NEW DATE"
FROM EMP;
Good Luck 😊