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

MTA SQL - LAB Assignment 2019 - 20

The document outlines database assignments on creating tables, inserting records, performing queries and updates. It includes creating tables for salespeople, orders, customers with fields like snum, sname, city, commission. Tasks involve writing queries for inserting, updating, deleting records and joining tables. Other tasks cover indexing, views, functions, triggers and string operations.

Uploaded by

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

MTA SQL - LAB Assignment 2019 - 20

The document outlines database assignments on creating tables, inserting records, performing queries and updates. It includes creating tables for salespeople, orders, customers with fields like snum, sname, city, commission. Tasks involve writing queries for inserting, updating, deleting records and joining tables. Other tasks cover indexing, views, functions, triggers and string operations.

Uploaded by

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

ATSS’s

Institute of Industrial & Computer Management & Research, Nigdi.


Academic year – 2019-2020
MCA I – Semester –I
LAB Assignment
Subject : Open Subject 1 & 2 - LAB ( OS-11 & OS-12 : Database Fundamentals & SQL)
Date:
Submission Date :

Sr.
Name Of Program
No.
1. Create table Salespeople with fields snum, sname, city, commission, contact
create table salespeople1(
snum int primary key,
saname varchar(50),
city varchar(50),
commission int not null,
contact bigint)
2. Orders table with field's onum, odate, snum, cnum,amt
create table order1(onum int primary key,
odate datetime,
snum int references salespeople1(snum),
1
cnum int references customer(cnum),
amt int not null
)
3. Customers table with field's cnum, cname, city, rating, Contact
create table customer(cnum int primary key,
cname varchar(50),
city varchar(50),
rating float,
contact bigint
)
2 1. Insert records in the table Salespeople, Orders, Customers by single insertion, insert all and multiple
insertion. Write query to display all records of table
insert into salespeople1 values(11,'xyz','pune',500,8456123)
insert into salespeople1

1
values(12,'onkar','pune',1000,84556123)
insert into salespeople1
values(13,'savya','somatnephata',2000,8880021455)
insert into salespeople1
values(14,'abhishek','prayagraj',25000,9896546512)
insert into salespeople1
values(15,'kuldeep','delhi',1000,845787495)
insert into salespeople1
values(16,'milind','pune',500,8456123)

1. Update commission of all salespeople by 5.


2. Delete records of customer of city ‘DELHI’
3
3. Count distinct salespeople from orders
4. Select details of salespeople where commission is greater than 10.
1. Assume commission is 15%. Find commission of salespeople for date ’15-aug-17’.
2. Display all customers where city is either 'PUNE' or 'MUMBAI' and rating is more than 50
4
3. Display all orders by date in descending order
4. Display all salespeople as per their commission.
1. Display the numbers of sales persons, with orders currently in the orders table without any repeats
2. Find total amount of orders on date ’15-aug-17’.
5
3. Find maximum and minimum amount order details of ‘PUNE’ city.
4. Find average amount of orders given by customer 5.
1. Display all customers names starting with character 'a', the 3rd character is ‘i’, fifth is ‘a’ & any other
characters.
6
2. Find all salespeople having commission from 10 to 30.
3. Find all salespeople having commission 10 and city Pune
1. Display the largest order taken by each salesperson on each date.
7 2. Display the details of maximum orders above 3000.
3. Display customer's highest ratings in each city.
1. Write a query that totals the orders for each day & places the results in descending order.
8 2. Find out count of salespeople by making group of commission having commission greater than 10
3. Find out average rating of customers by grouping them with their city.
1. Add ‘contact’ column by type number in customer table
9 2. Modify table and change data type for ‘contact’ column to varchar(10)

1. Add primary key for ‘snum’ column in Salespeople table


2. Add primary key for ‘cnum’ column in Customers table
10 3. Add primary key for ‘onum’ column in Oredrs table
4. Add following foreign keys for ‘ Orders’ table
a. snum,cnum
1. Create table department (dept_id (PK), dept_name, dept_loc.
2. Create table jobgrade (grade_name (PK), low_level, high_level)
11
3. Create table employee (emp_id (PK), fname, lname, join_date, manager_id(FK), email, contact, salary)
4. Inserts appropriate records in the table

2
1. Display names of all customers matched with the names of salespeople in the database
2. Create a union of two queries that shows the names, cities & ratings of all customers. Those with a rating of
12 200 or greater will also have ratings "high rating", while the others will have the words "low rating".
3. Write a command that produces the name & number of each salesperson & each customer with more than
one current order. Put results in alphabetical order.

1. Write a query that uses a sub-query to obtain all orders for the customer named 'Gopal'. Assume you do not
know the customer number
13 2. Write a query that produces the names & ratings of all customers who have above-average orders.
3. Write a query that selects the total amt in orders for each salesperson for whom this total is greater than the
amount of the largest order in table

1. Find all orders by customers not located in same cities as their Salespersons.
2. select name & city of sales person who brought orders having amount greater than 15000
14
3. Select orders with their salespeople along with salespeople not brought orders
4. Find commission of salespeople for all orders in the order table. (Cross Join)

1. Find the square root of 167 and display the answer in absolute value
2. Find out power of 15.2456 and display the answer by rounding it up to 2 decimal points.
15
3. Find 168.5 %23 and display absolute result.
4. Find out floor and ceil of 128.485 & 76.65

1. Find out name, city and rating of customer, display name & city in capital letters.
16 2. Display details of employee with first letter of every word as capital
3. Show usage of string function substr() & length
1. Find out number of months of salespeople that they are bringing orders.
17 2. Find out the date of Thursday after 02-sep-15
3. Find out the date after 6 months from first order of every salespeople.
1. Create view of giving details about salespeople having commission between 15 and 30.
2. Create view with name & city of salespeople & total number of their orders with amount.
3. Create index on sname of salespeople
18
4. Create index on odate of orders
5. Show usage of Synonym
6. Show usage of Sequence
1. Write function ‘fJdate( )’ which will accept ‘emp_id’ and return his joining date.
19 2. Display all employees whose joining date falls between year 2011 to 2017. Use ‘fJdate( )’ to retrieve joining
date of employee.
1. Write a ‘instead of ‘ trigger for employees table which will moves the record on ‘delete’ to ‘emptemp’
20
table.

You might also like