SQL Queries Full
SQL Queries Full
8.To display the teacher no. and name of the teachers whose name starts with letter ‘s’
9.To insert a new record with values 111,”ASHOK SINGHAL”,45000,”1999-08-11” for Tno
TNAME,SALARY,DOJ
mysql> insert into teacher(Tno,Tname,salary,DOJ)
-> values(111,"ASHOK SINGHAL",45000,"1995-08-11");
Query OK, 1 row affected (0.21 sec)
10.To display the record for which DEPT_NO is null
11.To set the value of DEPT_NO as “D04” for the department numbers having null values
And then display all the records
mysql> update teacher
-> set dept_no="D04" where dept_no is null;
Query OK, 1 row affected (0.16 sec)
Rows matched: 1 Changed: 1 Warnings: 0
12.To display the department number available In the school.
13.To increase the salary by 100 and set DOJ as “2006-12-11” for the teacher number 101
And then display all records
14.To display all the records of the teacher whose salary is between 61000 and 68000
15. To display all the records of the teachers whose salary is not between 51000 and
61000
16. To display the teacher number and name of the teachers of DEPT_NO D01,
D04,DO5.(USE IN operator)
17. To display the teachers whose date of joining is after 2005-01-01 and have the salary
more than 60000.
18. To display the records of the teachers whose salary is either less than 50,000 or
belong to department number D05
19. To display the teacher number, name and 20 percent of the salary(given alias
"BONUS")
20. To display the minimum and maximum salary from the table.
21. To display the department number and average salary of each department.
22. To display the teacher number, name and maximum annual salary(alias
"MAXIMUM ANNUAL SALARY") of the teacher.
23. Insert another record with values 112, "CHETAN SHUKLA", 55000, 2001-06-13"
for the field TNO, TNAME, SALARY, DOJ respectively and then display all the
records.
26. To display the total number of unique department numbers in the school.
27. To display department wise total salary with total number of departments
28. To display department wise total salary with total number of departments for the
records where total department number count is more than 2.
30. To display the highest salary from each department for those teachers whose salary
is more than 60000
31. To display all the records in the sorted order of department number.
32. To display all the records in the descending order of date of joining.
33. To display the teacher number, name and date of joining of the teacher who has
joined latest.
34. To display all the records of the teachers who have joined after the year 2005
35. To display the teacher number, name month and year of joining of the teachers
whose department number is NULL
43. Create a table 'DEPT' with fields DEPT_NO and DNAME(Department no and
department Name)
46.Display the dept name and total salary of each dept in ascending order
SQL
Queries