0% found this document useful (0 votes)
19 views

Exp 6 SQL

Uploaded by

Desmond Krej
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Exp 6 SQL

Uploaded by

Desmond Krej
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Program 06: DQL and Sorting Data

Exercise -1: Queries based on Conditional Retrieval of Rows

1. List department names and location from the department table.

OUTPUT

2. List the belonging to the department 20.

OUTPUT
3. List the name and salary of the employees whose salary is more
than 1000.

OUTPUT

4. List the name of clerks working in the department 20.

OUTPUT

5. List the names of analysts and salesmen.


OUTPUT

6. List the details of the employees who have joined before the end of
September 1981.

OUTPUT

Exercise -2: Special Operators IN and BETWEEN


1. List the name of the employee whose employee numbers are
7369,7521,7839,7934, 7788.

OUTPUT

2. List the employee details not belonging to the department 10, 30


and 40.

OUTPUT

3. List the employee name and salary, whose salary is between 1000
and 2000.
OUTPUT

Exercise -3: DISTINCT Clause with SELECT

1. List the different jobs (designations) available in the EMP table.

OUTPUT

Exercise -4: Working with NULL Values


1. List the employee names, who are not eligible for commission.

OUTPUT

2. List the employees not assigned to any department.

OUTPUT

3. List the employees who are eligible for commission.


OUTPUT

4. List the details of employees, whose salary is greater than 2000 and
commission is NULL.

OUTPUT

Exercise -5: Matching Pattern with Column


1. List the employees whose name start with an “S”.

OUTPUT

2. List the employees names ending with an “S”.

OUTPUT

3. List the names of employees whose name have exactly 5


Characters.
OUTPUT

4. List the employee names having “I” as the second character.

OUTPUT

Exercise -6: Using Expression with Column


1. List the name, salary and PF amount of all the employees (PF is
calculated as 10% of salary).

OUTPUT

2. List the names of employees, who are more than 2 years old in the
organization.

Exercise -7: Ordering the Results of a query


ORDER BY clause to impose an order on the result of a query,
ORDER BY clause used with SELECT statement.
SYNTAX: SELECT [DISTINCT] | FROM table name WHERE cond ORDER BY
col [ASC|DESC].
One or more column can be specified in ORDER BY clause.

1. List the empno, ename, sal in ascending order of salary.

OUTPUT

2. List the employee name and hiredate in descending order of


Hiredate.
OUTPUT

3. List the employee name, salary, job and department No. in


ascending order of Department No. in ascending order of
Department No and then on descending descending order of salary.
OUTPUT

You might also like