Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
550 views

Module 5 Assignment - SQL

The document describes a module 5 SQL assignment. The tasks are to: 1. Order a dataset by amount descending 2. Create and populate two tables with employee data 3. Apply the union operator to combine the tables 4. Apply the intersect operator to find matching rows 5. Apply the except operator to find rows only in the first table Solutions for each task are provided using SQL queries and showing the results.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
550 views

Module 5 Assignment - SQL

The document describes a module 5 SQL assignment. The tasks are to: 1. Order a dataset by amount descending 2. Create and populate two tables with employee data 3. Apply the union operator to combine the tables 4. Apply the intersect operator to find matching rows 5. Apply the except operator to find rows only in the first table Solutions for each task are provided using SQL queries and showing the results.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Module-5 Assignment

Problem Statement:
You have successfully cleared your 4th semester. In the 5th semester you will work with group by, having
by clauses and set operators

Tasks to be done:

1. Arrange the ‘Orders’ dataset in decreasing order of amount


2. Create a table with name ‘Employee_details1’ and comprising of these columns – ‘Emp_id’,
‘Emp_name’, ‘Emp_salary’. Create another table with name ‘Employee_details2’, which
comprises of same columns as first table.
3. Apply the union operator on these two tables
4. Apply the intersect operator on these two tables
5. Apply the except operator on these two tables

Solutions

1.
SELECT * FROM orders
ORDER BY amount DESC

RESULT

Order_id order_date amount customer_id


1004 2021-10-18 200 4
1002 2021-10-16 150 2
1003 2021-10-17 100 3
1001 2021-10-15 100 1

2.

CREATE TABLE Employee_details1 (


Emp_id INT,"Emp_name" VARCHAR (20), Emp_salary INT
)

/2

ANITA BALAKRISHNAN EMAIL annkallid@gmail.com MODULE 5 ASSIGNMENT - SQL


-2-

INSERT INTO Employee_details1


VALUES
(1, 'John', 10000),
(2, 'James', 15000),
(3, 'Ann', 25000),
(4, 'Sara', 20000),
(5, 'Laura', 35000)

CREATE TABLE Employee_details2


(Emp_id INT,"Emp_name" VARCHAR (20), Emp_salary INT)

INSERT INTO Employee_details2


VALUES
(1, 'Jimmy', 40000),
(2, 'James', 15000),
(3, 'Ann', 25000),
(4, 'Susy', 30000),
(5, 'Lennie', 35000)

3.

SELECT * FROM Employee_details1


UNION
SELECT * FROM Employee_details2

RESULT

Emp_id Emp_name Emp_salary


1 Jimmy 40000
1 John 10000
2 James 15000
3 Ann 25000
4 Sara 20000
4 Susy 30000
5 Laura 35000
5 Lennie 35000

4.
SELECT * FROM Employee_details1
INTERSECT
SELECT * FROM Employee_details2

RESULT

Emp_id Emp_name Emp_salary


2 James 15000
3 Ann 25000

/3

ANITA BALAKRISHNAN EMAIL annkallid@gmail.com MODULE 5 ASSIGNMENT - SQL


-3-

5.

SELECT * FROM Employee_details1


EXCEPT
SELECT * FROM Employee_details2

RESULT

Emp_id Emp_name Emp_salary


1 John 10000
4 Sara 20000
5 Laura 35000

ANITA BALAKRISHNAN EMAIL annkallid@gmail.com MODULE 5 ASSIGNMENT - SQL

You might also like