Dbt Lab Exam Faqs

3
Connect to Oracle database with your respective username and password. Run the file Demobld7.sql in SQL*Plus. Section I Write SELECT statements to achieve the following:- 1. Display the SAL column rounded off to the nearest thousand. 2. Display the last day of the month for every HIREDATE. 3. Display today’s date in the following format:- 7th Jan, 2005. 4. Display the average SAL for all the employees whose job is CLERK. 5. Display the maximum SAL deptwise. 6. Display the annual SAL for each employee. 7. Display the JOB column with duplicate values suppressed. 8. Display the rows where ENAME begins with the letter ‘A’. 9. Display the ENAME and the corresponding manager’s ENAME. 10. Display the ENAME and JOB for all employees who belong to the same DEPTNO as employee ‘KING’. 11. Display the Enames and the corresponding Dnames. 12. If all employees not receiving a commission are entitled for $300, find the net earnings (sal+comm) of each employee. 13. Find the names of all employees whose name begins with ‘M’. 14. Find the names of all employees hired in the month of February (of any year). 15. Find the names of all employees who were hired more than 12 years ago. 16. Display the names of all employees with the initial letter only in capital. 17. Show the first three characters of the names of all employees. 18. Display the names of all employees replacing any ‘A’ with ‘a’. 19. Show the salaries of all employees rounding it to the nearest 1000. 20. Find the total number of CLERKs joined after ’01-Jan-81’. 21. Find the names of all MANAGERs who are not in department 30. 22. List the employee name and employee number of the employees with the headings as NUMBER and NAME. 23. Find the names of all employees who do not receive any commission. 24. Find the names of all employees whose name ends with letter ‘M’. 25. Find the names of all employees who have a letter ‘R’ as a third letter in their name. 26. Find the names of all employees who were hired on the last day of the month. 27. Display the names of all employees right-aligning them to 15 characters. 28. Display the position at which the string ‘AR’ occurs in the name. 29. Find the names of all employees hired in the month of February (of any year). 30. Find the name of the employee who is receiving the maximum salary. 31. Display the remainder of 9 divided by 5. 32. Display the number of months (rounded off) between SYSDATE and HIREDATE. 33. Display today’s date in the following format:- Saturday, October 22, 2005. 34. Display the sum of SAL for all the employees belonging to DEPTNO 10. 35. Display the minimum SAL jobwise. 36. Display the HRA for each employee given that HRA is 20% of SAL. 37. Display the DEPTNO column with duplicate values suppressed. 38. Display the rows where JOB column ends with the letter ‘T’. 39. Display the DNAME and the corresponding ENAME. All rows of DEPT table are to be displayed even if a particular DEPTNO has no employees. 40. Display the ENAME and SAL for the employee who’s getting the minimum SAL.

description

This is an DBT Lab Exam Faqs.These are very very important questions.

Transcript of Dbt Lab Exam Faqs

Page 1: Dbt Lab Exam Faqs

Connect to Oracle database with your respective username and password. Run the file

Demobld7.sql in SQL*Plus.

Section I

Write SELECT statements to achieve the following:-

1. Display the SAL column rounded off to the nearest thousand.

2. Display the last day of the month for every HIREDATE.

3. Display today’s date in the following format:- 7th Jan, 2005.

4. Display the average SAL for all the employees whose job is CLERK.

5. Display the maximum SAL deptwise.

6. Display the annual SAL for each employee.

7. Display the JOB column with duplicate values suppressed.

8. Display the rows where ENAME begins with the letter ‘A’.

9. Display the ENAME and the corresponding manager’s ENAME.

10. Display the ENAME and JOB for all employees who belong to the same DEPTNO as

employee ‘KING’.

11. Display the Enames and the corresponding Dnames.

12. If all employees not receiving a commission are entitled for $300, find the net

earnings (sal+comm) of each employee.

13. Find the names of all employees whose name begins with ‘M’.

14. Find the names of all employees hired in the month of February (of any year).

15. Find the names of all employees who were hired more than 12 years ago.

16. Display the names of all employees with the initial letter only in capital.

17. Show the first three characters of the names of all employees.

18. Display the names of all employees replacing any ‘A’ with ‘a’.

19. Show the salaries of all employees rounding it to the nearest 1000.

20. Find the total number of CLERKs joined after ’01-Jan-81’.

21. Find the names of all MANAGERs who are not in department 30.

22. List the employee name and employee number of the employees with the headings as

NUMBER and NAME.

23. Find the names of all employees who do not receive any commission.

24. Find the names of all employees whose name ends with letter ‘M’.

25. Find the names of all employees who have a letter ‘R’ as a third letter in their name.

26. Find the names of all employees who were hired on the last day of the month.

27. Display the names of all employees right-aligning them to 15 characters.

28. Display the position at which the string ‘AR’ occurs in the name.

29. Find the names of all employees hired in the month of February (of any year).

30. Find the name of the employee who is receiving the maximum salary.

31. Display the remainder of 9 divided by 5.

32. Display the number of months (rounded off) between SYSDATE and HIREDATE.

33. Display today’s date in the following format:- Saturday, October 22, 2005.

34. Display the sum of SAL for all the employees belonging to DEPTNO 10.

35. Display the minimum SAL jobwise.

36. Display the HRA for each employee given that HRA is 20% of SAL.

37. Display the DEPTNO column with duplicate values suppressed.

38. Display the rows where JOB column ends with the letter ‘T’.

39. Display the DNAME and the corresponding ENAME. All rows of DEPT table are to

be displayed even if a particular DEPTNO has no employees.

40. Display the ENAME and SAL for the employee who’s getting the minimum SAL.

Page 2: Dbt Lab Exam Faqs

Section II

1. Write a stored procedure by the name of NUM_100 to tell whether the product of two

numbers is less than, equal to or greater than 100. The two numbers are to be passed

to the stored procedure as parameters. The stored procedure should display the

appropriate message on the screen using dbms_output.put_line. Calling program for

the stored procedure need not be written.

2. Write a stored function by the name of DIST_FUNC to convert a number of inches

into yards. For example, 36 inches equals 1 yard. The number of inches is to be

passed to the stored function as a parameter. The stored function should return the

truncated number of yards with the help of return statement. Calling program for the

stored function need not be written.

3. Write a stored procedure by the name of Simp_intr to calculate the amount of interest

on a bank account. The formulae are:-

Intr = p*t*r/100

Amt = p + Intr

where:-

Intr is the total interest earned.

p is the principal,

t is the number of years the money is earning interest, and

r is the rate of interest.

Your stored procedure should accept the values of p, t and r as parameters and display

the Interest and Total amount on the screen. Display the results on the screen using

dbms_output.put_line. Calling program for the stored procedure need not be written.

4. Write a stored function by the name of Num_cube. The stored function should return

the cube of a number ‘N’. The number ‘N’ should be passed to the stored function as

a parameter. Calling program for the stored function need not be written.

5. Write a stored procedure by the name of HRA_calc. The Empno, Deptno and Sal

should be passed as parameters to your stored procedure. The formulae are as

follows:-

If deptno = 10 then HRA = 20% of sal,

If deptno = 20 then HRA = 30% of sal,

For all other deptnos, HRA = 10% of sal.

Your stored procedure should display the Empno, Deptno, Sal and the HRA on the

screen. Display the results on the screen using dbms_output.put_line. Calling program

for the stored procedure need not be written.

6. Write a stored function by the name of Years_between. The stored function should

accept ‘D1’ and ‘D2’ as date parameters. The stored function should return the

truncated number of years between the two dates. Calling program for the stored

function need not be written.

Page 3: Dbt Lab Exam Faqs

7. Write a stored procedure by the name of RECT_PROC that computes the perimeter

and the area of a rectangle. The length and width are to be passed as parameters.

(Assuming that L and W are the length and width of the rectangle, Perimeter =

2*(L+W) and Area = L*W). The stored procedure should display the perimeter and

the area on the screen using dbms_output.put_line. Calling program for the stored

procedure need not be written.

8. Create a stored function by the name of F2C to convert a temperature in Fahrenheit

(F) to its equivalent in Celsius (C). The temperature in Fahrenheit is to be passed to

the stored function as a parameter. The stored function should return the temperature

in Celsius. The required formula is:-

C= (F-32)*5/9

Calling program for the stored function need not be written.