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

DBMS Lab 1

The document contains a series of SQL exercises performed by Syed Humail Mustafa, including queries to display employee data, department structure, and unique job codes. It also identifies errors in a SQL statement and instructs the user to solve questions on LeetCode. The exercises demonstrate practical applications of SQL in database management.

Uploaded by

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

DBMS Lab 1

The document contains a series of SQL exercises performed by Syed Humail Mustafa, including queries to display employee data, department structure, and unique job codes. It also identifies errors in a SQL statement and instructs the user to solve questions on LeetCode. The exercises demonstrate practical applications of SQL in database management.

Uploaded by

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

NAME: Syed Humail Mustafa​ ​ ​ ​ ​ Roll No : CT-23082

LAB 1 Exercises:

1.​ Display the last name concatenated with the job ID, separated by a comma and space, and name
the column Employee and Title.

QUERY:
SELECT LAST_NAME || ', ' || JOB_ID AS "Employee and Title" FROM HR.EMPLOYEES;

2.​ Create a query to display all the data from the EMPLOYEES table. Separate each column by a
comma. Name the column THE_OUTPUT.

QUERY:​
SELECT EMPLOYEE_ID || ', ' || FIRST_NAME || ', ' || LAST_NAME || ', ' || EMAIL || ', '
|| PHONE_NUMBER || ', ' || HIRE_DATE || ', ' || JOB_ID || ', ' || SALARY || ', ' ||
COMMISSION_PCT || ', ' || MANAGER_ID || ', ' || DEPARTMENT_ID AS "THE_OUTPUT"
FROM HR.EMPLOYEES;

3.​ Show the structure of the DEPARTMENTS table. Select all data from the table.

QUERY:
SELECT * FROM HR.DEPARTMENTS;

4.​ Show the structure of the EMPLOYEES table. Create a query to display the last name, job code,
hire date, and employee number for each employee, with employee number appearing first.

QUERY:
SELECT EMPLOYEE_ID, LAST_NAME, JOB_ID, HIRE_DATE FROM HR.EMPLOYEES;

5.​ Create a query to display unique job codes from the EMPLOYEES table.

QUERY:​
SELECT DISTINCT JOB_ID FROM HR.EMPLOYEES;

Database Management System


NAME: Syed Humail Mustafa​ ​ ​ ​ ​ Roll No : CT-23082

6.​ There are four coding errors in this statement. Can you identify them?
SELECT employee_id, last_name sal x 12 ANNUAL SALARY FROM employees;

ERRORS:
1)​ No Comma between last name and sal
2)​ Use * for multiplication instead of x
3)​ AS keyword before ANNUAL SALARY to use alias
4)​ ANNUAL SALARY should be in inverted commas

7.​ Make account on leetcode, head to https://leetcode.com/studyplan/top-sql-50/ and solve 5


questions in the select tag. The questions involve usage of “Where” clause.

1)

Database Management System


NAME: Syed Humail Mustafa​ ​ ​ ​ ​ Roll No : CT-23082

2)

Database Management System


NAME: Syed Humail Mustafa​ ​ ​ ​ ​ Roll No : CT-23082

3)

Database Management System


NAME: Syed Humail Mustafa​ ​ ​ ​ ​ Roll No : CT-23082

4)

Database Management System


NAME: Syed Humail Mustafa​ ​ ​ ​ ​ Roll No : CT-23082

5)

Database Management System

You might also like