Dhruv Pillai IP Project#
Dhruv Pillai IP Project#
Dhruv Pillai IP Project#
Class XI G
SET-1
Instructions:
Order of writing
Question
SQL query
Output: Draw table for select query output (draw table using pencil)
1. To create a database
2. To create student table with the student id, class, section, gender, name, dob, and marks as attributes
where the student id is the primary key.
CLASS INT,
SECTION CHAR(1),
GENDER CHAR(1),
DOB DATE,
MARKS FLOAT);
MYSQL> INSERT INTO STUDENT VALUES(501, 11, 'C', 'M', 'ISAAM', '2005-01-20', 80);
MYSQL> INSERT INTO STUDENT VALUES(602, 10, 'A', 'F', 'FIZZA', '2006-05-10', 85);
MYSQL> INSERT INTO STUDENT VALUES(603, 10, 'B', 'F', 'ISHA', '2006-07-15', 80);
MYSQL> INSERT INTO STUDENT VALUES(505, 11, 'D', 'M', 'RAZIL', '2005-10-25', 60);
MYSQL> INSERT INTO STUDENT VALUES(506, 12, 'E', 'M', 'ALEX', '2005-03-18', 45);
MYSQL> INSERT INTO STUDENT VALUES(507, 12, 'A', 'M', 'SAM', '2005-12-12', 50);
MYSQL> INSERT INTO STUDENT VALUES(607, 10, 'B', 'F', 'MARIA', '2006-02-15', 70);
MYSQL> INSERT INTO STUDENT VALUES(608, 10, 'E', 'F', 'TANISHA', '2006-04-11', 65);
MYSQL> INSERT INTO STUDENT VALUES(509, 11, 'B', 'M', 'AKHIL', '2005-03-01', 40);
MYSQL> INSERT INTO STUDENT VALUES(510, 11, 'B', 'M', 'ARIL', '2005-06-18', 90);
Output:
5. To display Student id, Name and Marks of those students who are scoring marks more than 50.
Output:
8. To display the information all the students, whose name starts with ‘AK’
Output:
9. To display Sid, Name, DOB of those students who are born between ‘2005- 01-01’ and ‘2005-12-31’.
MYSQL> SELECT SID, NAME, DOB FROM STUDENT WHERE DOB BETWEEN '2005-01-01' AND '2005-12-
31';
Output:
10. To display Student ID, Name, DOB and Marks of male students in ascending order of their names.
MYSQL> SELECT SID, NAME, DOB, MARKS FROM STUDENT WHERE GENDER LIKE 'M' ORDER BY NAME;
Output:
11. To display Student ID, Gender, Name, DOB, Marks in descending order of their marks.
MYSQL> SELECT SID, GENDER, NAME, DOB, MARKS FROM STUDENT ORDER BY MARKS DESC;
Output:
12. To display the unique section available in the table.
Output:
SET-2
1. Display the teacher names and the departments in which they are working
MYSQL> SELECT TNAME, DEPT FROM TEACHER;
Output:
6. Display the names of teachers having salary above 4000 working in MATHS department
MYSQL> SELECT TNAME, SALARY, DEPT FROM TEACHER WHERE SALARY>4000 AND DEPT LIKE
“MATHS”;
Output:
7. Display the details of teachers drawing salary in the range of 3500 to 4500
MYSQL>SELECT * FROM TEACHER WHERE SALARY BETWEEN 3500 AND 4500;
Output:
11. Sort and display teacher names first by department and then by teacher names
MYSQL>SELECT TNAME, DEPT FROM TEACHER ORDER BY DEPT, TNAME;
Output:
12. Display teacher name and department names who are not working in MATHS and COMPUTER
department
MYSQL>SELECT TNAME, DEPT FROM TEACHER WHERE DEPT NOT IN ('MATHS', 'COMPUTER');
Output:
13. Display teachers who are working in SCIENCE and COMPUTER department
MYSQL>SELECT TNAME, DEPT FROM TEACHER WHERE DEPT IN ('SCIENCE', 'COMPUTER');
Output:
19. Assign 10% bonus to those teacher who are getting salary below 4000
Output:
21. Find the number of teachers getting salary above 4000
MYSQL> select count(tname) from teacher where salary>4000;
Output:
24. Find the maximum and minimum salary paid to teachers and display with column headings
Highest Salary and Lowest Salary
MYSQL> select max(salary) as 'Highest Salary', min(salary) as 'Lowest Salary' from teacher;
Output: