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

22bce20428 DBMS Lab4

The document discusses 8 SQL queries performed on employee and department tables, including retrieving formatted birthdates, employee names by birth year, employees by address, departments by name, employee supervisors, and department names with substring functions.

Uploaded by

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

22bce20428 DBMS Lab4

The document discusses 8 SQL queries performed on employee and department tables, including retrieving formatted birthdates, employee names by birth year, employees by address, departments by name, employee supervisors, and department names with substring functions.

Uploaded by

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

VIT-AP UNIVERSITY, ANDHRA PRADESH

Name:- D.S.S.SASHANK
Reg No:- 22BCE20428
Slot:- L41 – L42

LAB-4
1) Display the bdate of all employee s in the format ‘DDthMonthYYYY’

SQL code:

SELECT CONCAT(DAY(Birthday), 'th', MONTHNAME(Birthday), YEAR(Birthday))


AS Formatted_BirthDate
FROM Employee;

OUTPUT:

2) Display the employee names whose bdate is on or before 2000.

SQL code:

SELECT CONCAT(firstName, ' ', lastName) AS Employee_Name


FROM Employee
WHERE YEAR(Birthday) <= 2000;

OUTPUT:
3) Display the employee names having ‘salt lake’ in their address

SQL code:

SELECT CONCAT(firstName, ' ', lastName) AS Employee_Name


FROM Employee
WHERE Address LIKE '%park road%';

OUTPUT:

4) Display the department name that starts with ’M’.

SQL code:

SELECT DName AS Department_Name


FROM Department
WHERE DName LIKE 'E%';

OUTPUT:

5) Display the department name that ends with ’g’.

SQL code:

SELECT DName AS Department_Name


FROM Department
WHERE DName LIKE '%g';

OUTPUT:

6) Display the names of all the employees having supervisor with any of the
following SSN '987-65-4321', '123-45-6789'

SQL code:
SELECT firstName, lastName
FROM Employee
WHERE SupervisorSSN IN ('987-65-4321', '123-45-6789');

OUTPUT:

7) Display all the department names in upper case and lower case

SQL code:

SELECT
UPPER(DName) AS UpperCaseDepartmentName,
LOWER(DName) AS LowerCaseDepartmentName
FROM Department;

OUTPUT:

8) Display the first four characters and last four of the department names using
substring
function

SQL code:

SELECT
SUBSTRING(DName, 1, 4) AS FirstFourCharacters,
SUBSTRING(DName, -4) AS LastFourCharacters
FROM Department;

OUTPUT:

You might also like