0% found this document useful (0 votes)
18 views6 pages

Practicle 3

The document discusses various SQL queries using predicates LIKE, BETWEEN, IN on tables employee, jobs and deposit. It includes queries to retrieve data, find records between dates, jobs with minimum salary greater than 15000, employee name and salary by department, employees between departments, various LIKE options, names starting with A and having a in third character, names of length 5 starting with Ani, non-null values with specific character in name, null values with character in name.

Uploaded by

Hamza Ravani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views6 pages

Practicle 3

The document discusses various SQL queries using predicates LIKE, BETWEEN, IN on tables employee, jobs and deposit. It includes queries to retrieve data, find records between dates, jobs with minimum salary greater than 15000, employee name and salary by department, employees between departments, various LIKE options, names starting with A and having a in third character, names of length 5 starting with Ani, non-null values with specific character in name, null values with character in name.

Uploaded by

Hamza Ravani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Practicle-3

Practical - 3. Perform queries involving predicates LIKE, BETWEEN, IN


etc.
1. Retrieve all data from employee, jobs and deposit.

 Query:

SELECT * FROM employee;

SELECT * FROM jobs;

SELECT * FROM deposit;

 Output:

1
Enrollment No: 220280107125 BE 3rd Sem CE,CE Dept,LDCE-A’bad-15
2. Give details of account no. and deposited rupees of customers
having account opened between dates 01-01-96 and 25-07-96.

 Query:

SELECT ACTNO, AMOUNT

FROM deposit

WHERE ADATE BETWEEN "96-01-01" AND "96-07-25";

 Output:

3. Display all jobs with minimum salary is greater than 15000.


 Query:

SELECT * FROM JOB WHERE min_sal > 15000;

 Output:

4. Display name and salary of employee whose department no is


20. Give alias name to name of employee.
 Query:

SELECT emp_name AS "Employee Name", emp_sal

FROM EMPLOYEE

WHERE dept_no = 20;

 Output:

2
Enrollment No: 220280107125 BE 3rd Sem CE,CE Dept,LDCE-A’bad-15
5. Display employee no, name and department details of those
employee whose department lies in(10,20).

 Query:

SELECT emp_name,emp_no,dept_no

FROM EMPLOYEE

WHERE dept_no BETWEEN 10 AND 20;

 Output:

6. To study various options of LIKE predicate.

 Query & Output:

-- Employees whose names contain 'AMAN':

SELECT * FROM EMPLOYEE WHERE emp_name LIKE '%AMAN%';

-- Employees whose names start with 'A':

3
Enrollment No: 220280107125 BE 3rd Sem CE,CE Dept,LDCE-A’bad-15
SELECT * FROM EMPLOYEE WHERE emp_name LIKE 'A%';

-- Employees whose names end with 'N':

SELECT * FROM EMPLOYEE WHERE emp_name LIKE '%N';

-- Employees whose names have 'ar' in the middle:

SELECT * FROM EMPLOYEE WHERE emp_name LIKE '%AM%';

7. Display all employee whose name start with ‘A’ and third
character is ‘a’.

 Query:

SELECT *

FROM EMPLOYEE

WHERE emp_name LIKE 'A_A%';

 Output:

8. Display name, number and salary of those employees whose


name is 5 characters long and first three characters are ‘Ani’.

4
Enrollment No: 220280107125 BE 3rd Sem CE,CE Dept,LDCE-A’bad-15
 Query:

SELECT emp_name, emp_no, emp_sal

FROM EMPLOYEE

WHERE emp_name LIKE 'ANI__';

 Output:

9. Display the non-null values of employees and also employee name


second character should be ‘n’ and string should be 5 character long.

 Query:

SELECT *

FROM EMPLOYEE

WHERE emp_name IS NOT NULL AND emp_name LIKE '_N___';

 Output:

10. Display the null values of employee and also employee name’s third
character should be ‘a’.
 Query:

SELECT *

FROM EMPLOYEE

WHERE emp_name IS NULL OR emp_name LIKE '__a%';

 Output:

11. What will be output if you are giving LIKE predicate as ‘%\_%’ ESCAPE ‘\.

5
Enrollment No: 220280107125 BE 3rd Sem CE,CE Dept,LDCE-A’bad-15
 This query will return rows where column name contains an underscore
character.

6
Enrollment No: 220280107125 BE 3rd Sem CE,CE Dept,LDCE-A’bad-15

You might also like