Assi1 5
Assi1 5
Answer:
Syntax:
[Constraints]
);
Here in this example, it says about book details. So, let’s take
name of table as tbl_book or book_tbl, or book_details or
book_master.
So, as you see above details are there according to above discussion:
Description Field-name
ISBN number of Book B_ISBN
Title of Book B_title
Price of Book B_price
Publisher of book B_publisher
Edition of book B_edition
Author’s name of book B_author
B_ISBN number(10),
B_title varchar(20),
B_price number(10,2),
B_publisher varchar(10),
B_edition varchar(10),
B_author varchar(10)
);
Practice Assignment-1
Aim: SQL DDL statements: CREATE TABLE
Password: admin123
Practice Assignment-2
Aim: SQL DDL statements: CREATE TABLE, DROP TABLE and ALTER
TABLE with ADD option
*******
Practice Assignment-3
Aim: More practice on create tables and INSERT INTO statement
Q-1: Decide table name as per following fields. And create the table.
Q-2: Decide table name as per following fields. And create the table.
Q-3: Decide table name and datatype as per following records. And
create the table.
Q-4: Decide table name and datatype as per following records. And
create the table.
******
NOTE:
Help for INSERT INTO Statement:
Syntax:
Values(value-1,valu-2,…..);
Example:
VALUES(11,’RAM’,MALE’,456,’25-JAN-2002’);
Display all the records using following statement:
SELECT *
FROM student;
SELECT SYSDATE
FROM DUAL;
****
Practical Assignment-1
Aim: CREATE TABLE with constraints AND INSERT INTO STATEMENT
CREATE FOLLOWING TABLES: STUDENT ENROLLMENT SYSTEM
NOTE: YOU CAN USE PRACTICAL ASSIGNMENT -1 TABLES FOR
ALL PRACTICAL WORK.
Practical Assignment-2
Aim:ALTER TABLE AND DROP TABLE STATEMENT.
Practical Assignment-3
Aim: SELECT statement with IN,BETWEEN, LIKE and
Logical operators
8. Display all those records course Title is ‘Basic English’ from course table.
9. Display all those records of students whose student id is ‘777349993’ from student
table.
10. Display all those records of students whose course number is ‘CIS326’ from
Enrollment table.
11. Display all those records of students whose grade is ’2’ from student table.
12. Display all those records of students whose course number is ‘CIS326’ from
Enrollment table.
13. To display all students that course number are in "CIS326", "NM204" or
14. To display all students that major are not in "English", "Art" or
15. To display all students where grade is “c” and courseno is “CIS326” from
Enrollment table.
16. To display all students where grade is “c” or grade is ”a” from
Enrollment table.
17. To display all students where Major is NOT "English " from student table.
18. To display all students where Major is “Business” and Status must be “1” OR “3”.
19. Display all records whose first name starting with "J" from student table.
20. Display all records whose first name ending with "y" from student table .
21. Display all records whose Instructor starting with "m" in any position.
22. Display all course title that have "a" in the second position.
23. Display all students with a lastName that starts with "J" and are at least 3
characters in length from student table.
Table Name:- Employee
Table :- EmpDept
DeptHea
DeptId DeptName Dept_off
d
E-101 HR Monday 105
E-102 Development Tuesday 101
E-103 House Keeping Saturday 103
E-104 Sales Sunday 104
E-105 Purchase Tuesday 104
Table :- EmpSalary
Table :- Project
ProjectId Duration
p-1 23
p-2 15
p-3 45
p-4 2
p-5 30
Table :-
EmpProject
EmpId ProjectId StartYear EndYear
101 p-1 2010 2010
102 p-2 2010 2012
103 p-3 2013
104 p-4 2014 2015
105 p-5 2015
Query:
5. Update the Dept_off=”Wednesday” for Employee whose ID number is E-102 in the table.
10. Display all those records of employee whose employee id is ‘101’ from Employee
table.
13. To display all department name that are not in "E-101", "E-102" or
"E-105".
16. Display all records whose department name ending with "t" .
17. Display all records whose department name starting with "L" in any position.
18. Display all employee name that have "s" in the second position.
19. To modified department name was ’sales’ and set it to a new name’hr’.
20. to find the details of all employee whose day_off is ‘monday’ or ‘Tuesday’.
SQL JOIN
5. Write a SQL query to display an employee name, contact no, email and
employee salary using employee and employee salary tables whose salary
is greater than 1000 and whose employee name starts with ‘N’.
6. Write a SQL query to display an employee email, employee contact no,
employee salary using Employee and employee salary tables.
7. Write a SQL query to display a project duration, start year, end year and
employee id using project and employee project tables.
8. Write a SQL query to display a start year, end year, employee id, project id,
duration using project and employee project tables whose start year from
2010.
9. Write a SQL query to display an employee email, employee contact no,
department off using employee and department tables whose the
department name is HR and Development.
10. Write a SQL query to find employee table to display an employee name,
employee email.
Table-name: Order-details
1. write a SQL query to calculate total purchase amount of all orders. Display total purchase
amount.
2. write a SQL query to calculate average purchase amount of all orders. Display average purchase
amount.
3. write a SQL query to count the number of unique salespeople. Display number of salespeople.
4. write a SQL query to find the maximum purchase amount.
5. write a SQL query to find the minimum purchase amount.
6. write a SQL query to count all the orders generated on '2012-08-17'. Display number of orders.
Table-name: customer_details
1. write a SQL query to find the highest grade of the customers for each of the city. Display city,
maximum grade.
2. write a SQL query to count the number of customers. Display number of customers.
3. write a SQL query to find the number of customers who got at least a gradation for his/her
activity.
4. write a SQL query to find the highest grade of the customers for each of the city. Display city,
maximum grade.
5. write a SQL query to find the highest purchase amount ordered by each customer. Display
customer ID, maximum purchase amount
Table-name: SALESMAN_details