0% found this document useful (0 votes)
3 views16 pages

SQL

The document outlines SQL tasks including creating and populating 'employee' and 'Customer' tables with specified fields and constraints. It also includes various SQL queries to retrieve customer details, calculate balances, and display employee information based on specific criteria. Additionally, it covers modifications to tables and data retrieval based on conditions such as names and salary ranges.

Uploaded by

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

SQL

The document outlines SQL tasks including creating and populating 'employee' and 'Customer' tables with specified fields and constraints. It also includes various SQL queries to retrieve customer details, calculate balances, and display employee information based on specific criteria. Additionally, it covers modifications to tables and data retrieval based on conditions such as names and salary ranges.

Uploaded by

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

SQL

QUES 1 - Create a table with the name ‘employee’ and


having following data items.
empnno char(2)
Lastname char(15)
Firstname char(15)
Street varchar2(15)
City char(15)
Credit_limit number(7,2)
Salary number (7,2)
b) Enter few data records.
QUES 2 - Write SQL statements for creating a table
Customer.
Customer (cust id, lastname, firstname, street, city, balance, credit Imt, sales
repno)

Impose all possible constraints on various fields. Enter sample data in the table
so created.

Run SQL queries to:

a) Find the minimum, maximum and average balance of all customers.

(MAXIMU
M)

(MINIMU
M)
(AVERAGE)

b) List customer details who live in city beginning with city name ‘A’.
QUES 3. Write SQL statements for creating a table
Customer.
Customer (cust _id, lastname, firstname, street, city, balance, credit Imt, sales
repno).

Enter sample data in the table so created.

Run SQI queries to:

a) Display the structure of the table created.

b) List customer id of all customers


c) Include the fields.’ TelNo' in the Customer Table.

d) List customer details who live in city beginning with city name "A".

e) List customer no. of those whose name has pattern “sons".


f) List customer details who have credit limit beyond 10 lakhs.

g) List customer details who have credit limit in the range 1 lakh to 5 lakhs.

h) Find the minimum, maximum and average balance of all customers.


i) Find the total balance of all customers.

j) List customer details who have credit limit beyond 10 lakhs in alphabetical
order of first name.
k) Add a new column customer-ranking.
QUES 4. Consider the sample tables:
Emp (empno,ename,job,sal,hiredate,deptno,comm)

dept (deptno, dname, loc)

Write the SQL queries for the following:-


a) Display the structure of the employee and dept data tables.
b) Display employee name, job and salary for all employees except managers.

c) Display employee name and department number for those hired between
January 1 1983 and January 1, 1982.

d) Display employee name, job and department number for all clerks and
analysts.
e) Display employee name, job, department number and hire date for those
whose name begins with capital letter 'M'.

f) Display employee name, job, department number and hire date for those
whose name begins with capital letter ‘J’ followed by two characters and
ending with 'ES’.

g) Display employee name, job and salary for managers and sales people
earning 2000 or more.
h) Display salary, job and employee names for department no. 10 in
descending salary order.

i) Display the employee names of those whose names contain the letter S.

j) Display employee names and salaries for those having salaries less than their
commission.
k) Display employees hired in 1981.

l) Display the names and jobs of all employees in department no. 10 and 20.
m) Display employees who are not clerks or salesmen

n) Add a new column EMPADDRESS to Emp table.


o) Display the employee who was hired last.

p) Display the average annual salary for all job types.

You might also like