Kumaran Manangatti Dharman Lekha Assignment 6 - Introduction To SQL
Kumaran Manangatti Dharman Lekha Assignment 6 - Introduction To SQL
Kumaran Manangatti Dharman Lekha Assignment 6 - Introduction To SQL
EMPLOYEE
DEPARTMENT
DEPT_LOCATIONS
WORKS_ON
PROJECT
DEPENDENT
Problem 1:
Display each record in the DEPT_LOCATIONS table. The heading of the columns should
be Dept Number for Dnumber and Dept Location for Dlocation.
SELECT Dnumber AS "Dept Number", Dlocation AS "Dept Location"
FROM DEPT_LOCATIONS;
Problem 2:
Using the employee table, extract the records where the individuals Dno is less than or equal to
4.
Display these columns
Fname using First Name
Lname using Last Name
Salary
Dno as Dept Number
SELECT Fname AS "First Name", Lname AS "Last Name", Salary, Dno AS "Dept Number"
from EMPLOYEE
Problem 3
Display all males earning at least 38000 in salary.
Show columns Fname, LName, Sex, Salary
SELECT Fname, Lname, Sex,Salary FROM
EMPLOYEE
WHERE sex = 'M'
AND salary >=38000;
Problem 4
Display all dependents whose name begins with the letter A.
Show columns Dependent_name, Sex, Relationship
SELECT Dependent_name, Sex, Relationship FROM DEPENDENT
WHERE DEPENDENT_NAME LIKE 'A%';
Problem 5
Select all dependents born in the 1980s.
Show columns Dependent_name, Bdate, Relationship
SELECT Dependent_name, Bdate, Relationship FROM DEPENDENT
WHERE Bdate >='01-01-80' AND
Bdate < '01-01-90';
Problem 6
Select all employees with an Ssn that contains a 3.
Display Fname (using FirstName), Lname (using FamilyName), SSN (using Social Security
Number)
SELECT Fname AS "Firstname", Lname AS "Familyname", Ssn AS "Social Security Number"
FROM EMPLOYEE
Problem 7
Extract all records in the WORKS_ON table with Hours greater than or equal 35.
Display all columns
SELECT *
FROM WORKS_ON
WHERE Hours >= 35;
Problem 8
Extract all records in the WORKS_ON table with Hours not between 20 and 40.
Display all columns
SELECT *
FROM WORKS_ON
WHERE Hours NOT BETWEEN 20 AND 40;
Problem 9
Select all dependents who are male spouses.
Show all columns.
SELECT * FROM DEPENDENT
WHERE Sex = 'M' AND
Relationship = 'Spouse';
Problem 10
Select all employees whose Ssn has a 4 as the 4th digit.
Show columns Lname and SSn.
SELECT Lname, Ssn
FROM EMPLOYEE
WHERE Ssn LIKE '___4%';