-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask3_students.sql
More file actions
84 lines (58 loc) · 2.89 KB
/
Copy pathTask3_students.sql
File metadata and controls
84 lines (58 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
create database Task3;
use Task3;
--Create students table
create table Students(
STd_id int not null primary key,
stdname varchar(255) not null,
Department varchar(255),
Marks int,
City varchar(255),
);
--Inserts the different records in student table
insert into students(std_id,stdname,department,marks,city)
values(1,'Nayyab','Computer Science',70,'Faisalabad');
insert into students(std_id,stdname,department,marks,city)
values(2,'Laiba','Computer Science',49,'Faisalabad');
insert into students(std_id,stdname,department,marks,city)
values(3,'Abeera','Software Engineering',68,'Sialkot');
insert into students(std_id,stdname,department,marks,city)
values(4,'Fatima','Cyber Security',90,'Lahore');
insert into students(std_id,stdname,department,marks,city)
values(5,'Rubab','Computer Science',82,'Gujranwala');
insert into students(std_id,stdname,department,marks,city)
values(6,'Muniba','Computer Science',72,'Lahore');
insert into students(std_id,stdname,department,marks,city)
values(7,'Maheen','Cyber Security',59,'Faisalabad');
insert into students(std_id,stdname,department,marks,city)
values(8,'Areeba','Software Engineering',61,'Sialkot');
insert into students(std_id,stdname,department,marks,city)
values(9,'Fatima','Cyber Security',95,'Islamabad');
insert into students(std_id,stdname,department,marks,city)
values(10,'Rimsha','Computer Science',84,'Gujranwala');
insert into students(std_id,stdname,department,marks,city)
values(11,'Musfirah','Information Technology',97,'Islamabad');
insert into students(std_id,stdname,department,marks,city)
values(12,'Abrish','Computer Science',80,'Faisalabad');
insert into students(std_id,stdname,department,marks,city)
values(13,'Fariha','Computer Science',84,'Gujranwala');
insert into students(std_id,stdname,department,marks,city)
values(14,'Zainab','Information Technology',77,'Islamabad');
insert into students(std_id,stdname,department,marks,city)
values(15,'Samia','Information Technology',89,'lahore');
--Sql query to retrieve/select all columns from student table
select *from students;
--sql query to select all students whose city is not lahore
select *from students
where city not in ('Lahore');
--Sql query to find maximum marks scored by any student
select max(marks) as MaxMarks from students;
--Sql query to find minimum marks scored by any student
select min(marks) as MinMarks from students;
--sql query to calculate tatal marks obtained by all students
select sum(marks) as TotalMarks from students;
--sql query to calculate average marks of students in Computer science department only
select avg(marks) as AvgMarksCS from students
where department = 'computer science';
--Sql query to find the total number of students from the Cyber Security department
select count(*) as TotalITStudents from students
where department = 'Cyber security';