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

LAB 1 Exercises

The document contains SQL queries and commands related to employee and department data management in a database. It includes instructions for displaying employee details, correcting SQL errors, and solving SQL problems on LeetCode. Additionally, it provides commands to show the structure of tables and filter data based on specific conditions.

Uploaded by

noor4601283
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)
0 views

LAB 1 Exercises

The document contains SQL queries and commands related to employee and department data management in a database. It includes instructions for displaying employee details, correcting SQL errors, and solving SQL problems on LeetCode. Additionally, it provides commands to show the structure of tables and filter data based on specific conditions.

Uploaded by

noor4601283
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

Dania Noor(CT-23010)

1. Display the last name concatenated with the job ID, separated by a comma and space, and name the
column Employee and Title.
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.
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;
Dania Noor(CT-23010)

3. Show the structure of the DEPARTMENTS table. Select all data from the table.
DESC hr.departments;

SELECT * FROM departments;


Dania Noor(CT-23010)

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.
DESC hr.employees;
Dania Noor(CT-23010)

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.
SELECT DISTINCT job_id FROM hr.employees;
Dania Noor(CT-23010)

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;

Corrected:
SELECT employee_id, last_name AS sal, salary * 12 AS "ANNUAL SALARY" FROM employees;
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. select product_id from Products where low_fats = 'Y' and recyclable = 'Y'

2. Select from Customer where referee_id != 2 or refree_id is null


Dania Noor(CT-23010)

3. select name, population, area from World where area >= 3000000 or population >= 25000000

4. select distinct author_id as id from Views where author_id = viewer_id order by author_id

5. select tweet_id from Tweets where length(content) > 15

You might also like