iprpact
iprpact
MYSQL Commands
Lab Record 22
Table: student
Answers
marks decimal(5,2));
Table data:
Q6) Group by
select ucase(name),lcase(name),left(name,3),right(name,3),instr(name,'a')
from student;
Q10) Text Functions
select ltrim(" Informatics Practices Class XII ") "Left Trim", rtrim("
Informatics Practices Class XII ") "Right Trim", trim(" Informatics
Practices Class XII ") “Both”;
select dayname(now()),monthname(now()),day(now()),dayname(now()),
dayofmonth(now()),dayofyear(now());
Lab Record 23
Table: Teacher
Write SQL Commands for the following based on given table.
1) Create a teacher table with the T_ID, Name, Age, Gender, Department,
Date_of_join, Salary and Post as attributes where the T_ID is the primary
key.
2) Insert the details of a new teacher in the above table.
3) Delete the details of a teacher in the above table.
4) To display all information of TGT teachers.
5) To display the name, post and salary of all teachers in ascending order of
their salaries.
6) To display the total salary of teachers who are in the same post.
7) To display teacher’s name in which ‘ee’ occurs anywhere in the name.
8) To display contents of “Department” field in small letters.
9) To display first 2 characters of the “Department” field.
10) To display 3 characters of teacher’s name starting from 2nd Character.
11) To display the name, age and joining date of teachers who joined in May
Month.
12) To display the name and salary of teacher’s after rounding off to the nearest
integer.
13) To display the department name and no of teachers in each department.
14) To display the maximum and minimum date of join of teachers.
15) To display the average salary of male teachers from the table.
Answers:
Post char(3));
Table: Employee
Table data
Select *from Employee;
Q3) Deleting records
delete from Employee where EMPNO=8521;
Table: Store
1) Create store table with the store Id, Name, Location, City, NoOfEmp,
DateOpen, SalesAmt where store id is the primary key.
2) Insert the details of a new store in the above table.
3) Display all the details of the stores with Number of employees more than 7.
4) To find the min, max sales amount of the Mumbai city.
5) To find the sum and average sales amount of Mumbai and Delhi city.
6) To display names of stores along with SalesAmount that have ‘Fashion’
anywhere in their store names.
7) To display stores names, location and Dateofopen of Stores that are opened
before 1st march 2015.
8) To display name, SalesAmount in ascending of no of employees from store
table.
9) To display city, sum of sales Amount located in that city.
10) To display the city and the number of stores located in that city, only if
number of stores is more than 2.
*****************************************************************