[Examination] Hệ thống quản lý sinh viên - SQL Server
Tags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)
Đào Mạnh Dũng
2021-04-15 14:21:40
create database StudentManagementSystem
use StudentManagementSystem
create table Class (
ClassId int not null primary key identity(1,1),
ClassCode nvarchar(50)
)
create table Student (
StudentId int not null primary key identity(1,1),
StudentName nvarchar(50),
BirthDate datetime,
ClassId int foreign key references Class(ClassId),
)
create table Subject (
SubjectId int not null primary key identity(1,1),
SubjectName nvarchar(100),
SessionCount int,
constraint check_Cout check (SessionCount > 0 )
)
create table Result (
StudentId int references Student(StudentId),
SubjectId int references Subject(SubjectId),
Mark int,
primary key (StudentId,SubjectId)
)
drop table Result
drop table Student
drop table Subject
insert into Class (ClassCode)
values
('C1106KV'),
('C1108GV'),
('C1108IV'),
('C1108HV'),
('C1109GV')
insert into Student (StudentName,BirthDate,ClassId)
values
('Phạm Tuấn Anh','1993-08-05',1),
('Phan Văn Huy','1992-06-10',1),
('Nguyễn Hoàng Minh','1992-09-07',2),
('Trần Tuấn Tú','1993-10-10',2),
('Đỗ Anh Tài','1992-08-05',3)
insert into Subject (SubjectName,SessionCount)
values
('C Programming',22),
('Web Design',18),
('Database Management',23)
insert into Result (StudentId,SubjectId,Mark)
values
(1,1,8),
(1,2,7),
(2,3,5),
(3,2,6),
(4,3,9),
(5,2,8)
select Student.StudentId,Student.StudentName,Student.BirthDate from Student
where Student.BirthDate between '1992-10-10' and '1993-10-10'
select Class.classId,Class.ClassCode, COUNT(Student.ClassId) 'TotalStudent'
from Class left join Student on Class.ClassId = Student.ClassId
GROUP BY Class.ClassCode,Class.ClassId
create trigger TG_Result_Insert on Result
for insert
as
begin
if (select count(*) from inserted where Mark < 0 ) > 0
begin
print 'Cannot insert mark < 0'
rollback transaction
end
end
insert into Result (StudentId,SubjectId,Mark)
values
(1,3,-2)
create trigger TG_Subject_Update on Subject
for UPDATE
as
begin
if UPDATE(SubjectName)
begin
print 'You don’t update this column'
rollback transaction
end
end
UPDATE Subject set SubjectName = 'abc' where SubjectName='Web Design'
Cao Tuấn Minh
2021-04-15 05:32:09
use StudentManagementSystem
go
create table Class(
ClassId int not null,
ClassCode nvarchar(50)
)
create table Student(
StudentId int not null,
StudentName nvarchar(50),
BirthDate datetime,
ClassId int
)
create table Subject(
SubjectId int not null,
SubjectName nvarchar(100),
SessionCount int
)
create table Result(
StudentId int not null,
SubjectId int not null,
Mark int
)
alter table Result
alter column Mark float;
alter table Class
add constraint PK_Class primary key (ClassId);
alter table Student
add constraint PK_Student primary key (StudentId);
alter table Subject
add constraint PK_Subject primary key (SubjectId);
alter table Result
add constraint PK_Result primary key (StudentId,SubjectId);
alter table Student
add constraint FK_Student_Class
foreign key (ClassId) references Class(ClassId);
alter table Result
add constraint FK_Result_Student
foreign key(StudentId) references Student(StudentId);
alter table Result
add constraint FK_Result_Subject
foreign key (SubjectId) references Subject(SubjectId);
alter table Subject
add check (SessionCount>0);
insert into Class (ClassId, ClassCode)
values
(1, 'C1106KV'),
(2, 'C1108GV'),
(3, 'C1108IV'),
(4, 'C1108HV'),
(5, 'C1109GV')
insert into Student (StudentId, StudentName, BirthDate, ClassId)
values
(1, 'PhạmTuấnAnh', 1993-08-05, 1),
(2, 'PhanVănHuy', 1992-06-10, 1),
(3, 'NguyễnHoàng Minh', 1992-09-07, 2),
(4, 'TrầnTuấnTú', 1993-10-10, 2),
(5, 'ĐỗAnhTài', 1992-06-06, 3)
insert into Subject (SubjectId, SubjectName, SessionCount)
values
(1, 'C Programming', 22),
(2, 'Web Design', 18),
(3, 'Database Management', 23)
insert into Result (StudentId, SubjectId, Mark)
values
(1, 1, 8),
(1, 2, 7),
(2, 3, 5),
(3, 2, 6),
(4, 3, 9),
(5, 2, 8)
select * from Student
select * from Class
select * from Subject
select * from Result
select Student.StudentId, Student.StudentName, Student.BirthDate
from Student
where Student.BirthDate between 1992-10-10 and 1993-10-10
select Class.ClassId, Class.ClassCode, count(Class.ClassId) 'Student Quantity'
from Class, Student
where Student.ClassId = Class.ClassId
group by Class.ClassId, Class.ClassCode
order by Class.ClassId asc;
select Student.StudentId, Student.StudentName, sum(Result.Mark) 'Total Mark'
from Student, Result
where Student.StudentId = Result.StudentId
group by Student.StudentId, Student.StudentName
having sum(Result.Mark)>10
create view view_StudentSubjectMark
as
select Student.StudentId, Student.StudentName, Subject.SubjectName, Result.Mark
from Student, Subject, Result
where Student.StudentId = Result.StudentId
and Subject.SubjectId = Result.SubjectId
select top 3 * from view_StudentSubjectMark
order by Mark desc;
create proc up_IncreaseMark
@SubjectId int
as
begin
select Student.StudentId, Student.StudentName, Subject.SubjectId, Subject.SubjectName, Result.Mark
from Student, Result, Subject
where Student.StudentId = Result.StudentId
and Subject.SubjectId = Result.SubjectId
end
exec up_IncreaseMark 2
drop proc up_IncreaseMark
Võ Như Việt
2021-04-12 17:15:00
create database He_Quan_Tri_SQL
use He_Quan_Tri_SQL
--tao bang Class--
create table Class(
ClassId int not NULL,
ClassCode nvarchar(50)
)
-- Tao bang Student--
create table Student(
StudentId int not NULL,
StudentName nvarchar(50),
BirthDate Datetime,
ClassId int
)
-- Tao Bang Subject --
create table Subject(
SubjectId int not NULL,
SubjectName nvarchar(100),
SessionCount int
)
-- Tao Bang Result--
create table Result(
StudentId int not NULL,
SubjectId int not NULL,
Mark int
)
-- y 3 tao
create nonclustered index NCL_Student_StudentName on Student(StudentName)
alter table Result
alter column Mark float
-- tao Primary key--
alter table Class
add constraint PK_Class primary key (ClassId)
alter table Student
add constraint PK_Student primary key (StudentId)
alter table Subject
add constraint PK_Subject primary key (SubjectId)
alter table Result
add constraint PK_Result primary key (StudentId,SubjectId)
-- tao foreign key--
alter table Student
add constraint FK_Student_Class foreign key (ClassId) references Class (ClassId)
alter table Result
add constraint FK_Result_Student foreign key (StudentId) references Student (StudentId)
alter table Result
add constraint FK_Result_Subject foreign key (SubjectId) references Subject (SubjectId)
-- check--
alter table Subject
add constraint CK_Subject_SessionCount check (SessionCount > 0)
-- insert data--
insert into Class(ClassId,ClassCode)
values
(1,'C1106KV'),
(2,'C1108GV'),
(3,'C1108IV'),
(4,'C1108HV'),
(5,'C1109GV')
insert into Student(StudentId,StudentName,BirthDate,ClassId)
values
(1,'PhạmTuấnAnh','1993-08-05',1),
(2,'PhạmVănHuy','1992-06-10',1),
(3,'NguyễnHoàngMinh','1992-09-07',2),
(4,'TrầnTuấnTú','1993-10-10',2),
(5,'ĐỗAnhTài','1992-06-06',3)
insert into Subject(SubjectId,SubjectName,SessionCount)
values
(1,'C Programming',22),
(2,'Web Design',18),
(3,'Database Management',23)
insert into Result(StudentId,SubjectId,Mark)
values
(1,1,8),
(1,2,7),
(2,3,5),
(3,2,6),
(4,3,9),
(5,2,8)
-- 6 Query Operation--
select StudentId as 'MãSinhViên',StudentName as 'TênSinhViên',BirthDate as 'NgàySinh'
from Student
where BirthDate between '1992-10-10' and '1993-10-10'
select Class.ClassId as 'MãLớp', Class.ClassCode as 'TênLớp' , Count(Student.ClassId) as 'SĩSốLớp'
from Class , Student
where Student.ClassId = Class.ClassId
group by Class.ClassId, Class.ClassCode
select Student.StudentId as 'MãSinhViên',Student.StudentName as 'TênSinhViên',
sum(Result.Mark) as 'TổngĐiểm'
from Result, Student
where Student.StudentId = Result.StudentId
group by Student.StudentId, Student.StudentName
having sum(Result.Mark) > 10
-- 7.View--
create view view_StudentSubjectMark
as
select Student.StudentId,student.StudentName,Subject.SubjectName,Result.mark
from Student,Subject, Result
where Student.StudentId = Result.StudentId
and Subject.SubjectId = Result.SubjectId
select * from view_StudentSubjectMark
--cach 2--
create view view_StudentSubjectMark
as
select Student.StudentId,student.StudentName,Subject.SubjectName,Result.mark
from Student left join Result on Student.StudentId = Result.StudentId
left join Subject on Result.SubjectId = Subject.SubjectId
--top (3)--
select top(3) * from view_StudentSubjectMark
order by Mark desc
--Procedures--
create proc up_IncreaseMark
@SubjectId int out
as
begin
update Result set Mark = Mark + 1 where SubjectId = @SubjectId
end
select * from Result where SubjectId = 2
exec up_IncreaseMark 2
Đỗ Phan Hà
2021-04-10 14:05:48
-- 1.Tạo database và dùng database --
create database StudentManagementSystem
use StudentManagementSystem
-- 2.Tạo bảng --
create table Class(
ClassId int not null,
ClassCode nvarchar(50)
)
create table Student(
StudentId int not null,
StudentName nvarchar(50),
BirthDate datetime,
ClassId int
)
create table Subject(
SubjectId int not null,
SubjectName nvarchar(100),
SessionCount int
)
drop table Result
create table Result(
StudentId int not null,
SubjectId int not null,
Mark int
)
-- 4.gắn Primary Key, Foreign Key và Check --
alter table Class add constraint PK_Class primary key (ClassId)
alter table Student add constraint PK_Student primary key (StudentId)
alter table Subject add constraint PK_Subject primary key (SubjectId)
alter table Result add constraint PK_Result primary key (StudentId, SubjectId)
alter table Student add constraint FK_Student_Class foreign key (ClassId) references Class(ClassId)
alter table Result add constraint FK_Result_Student foreign key (StudentId) references Student(StudentId)
alter table Result add constraint FK_Result_Subject foreign key (SubjectId) references Subject(SubjectId)
alter table Subject add constraint CK_SubjectSessionCount check(SessionCount > 0)
-- 5.Chèn dữ liệu
insert into Class(ClassId, ClassCode) values
(1, 'C1106KV'),
(2, 'C1108GV'),
(3, 'C1108IV'),
(4, 'C1108HV'),
(5, 'C1108GV')
select * from Class
insert into Student(StudentId, StudentName, BirthDate, ClassId) values
(1, 'Phạm Tuấn Anh', '1993-08-05', 1),
(2, 'Phan Văn Huy', '1993-06-10', 2),
(3, 'Nguyễn Hoàng Minh', '1992-09-07', 3),
Đinh Hữu Nghĩa
2021-04-10 14:05:14
--- create DATABASE
create database StudentManagementSystem
--- use database
use StudentManagementSystem
-- tạo classs
create table Class(
ClassId int NOT NULL,
ClassCode nvarchar(50)
)
create table student(
StudentId int NOT NULL,
StudentName NVARCHAR(50),
BirthDate DATETIME,
ClassId INT
)
create table Subject(
SubjectId INT NOT NULL,
SubjectName NVARCHAR(100),
SessionCount INT
)
create table Result(
StudentId INT NOT NULL,
SubjectId INT NOT NULL,
Mark INT,
)
--- đổi tt
create NONCLUSTERED INDEX NCI_Student_StudentName on student(StudentName);
ALTER TABLE Result
ALTER COLUMN Mark float
-- khóa chính
ALTER TABLE Class
ADD CONSTRAINT class_pk PRIMARY KEY (ClassId);
ALTER TABLE student
ADD CONSTRAINT student_pk PRIMARY KEY (StudentId);
ALTER TABLE Subject
ADD CONSTRAINT Subject_pk PRIMARY KEY (SubjectId);
-- khóa phụ
alter table Student
add constraint FK_Student_Class foreign key (ClassId) references Class(ClassId)
alter table Result
add constraint FK_Result_Student foreign key (StudentId) references Student(StudentId)
alter table Result
add constraint FK_Result_Subject foreign key (SubjectId) references Subject(SubjectId)
-- thêm hàm check
alter table Subject
add constraint CK_Subject_SessionCount check(SessionCount >0)
---inserting
insert into Class (ClassId,ClassCode)
values
(1,'C1106KV'),
(2,'C1108GV'),
(3,'C1108IV'),
(4,'C1108HV'),
(5,'C1109GV')
insert into Student (StudentId,StudentName,BirthDate,ClassId)
values
(1,'PhạmTuấnAnh','1993-08-05',1),
(2,'PhanVănHuy','1992-06-10',1),
(3,'NguyễnHoàng Minh','1992-09-07',2),
(4,'TrầnTuấnTú','1993-10-10',2),
(5,'ĐỗAnhTài','1992-06-06',3)
insert into Subject (SubjectId,SubjectName,SessionCount)
values
(1,'C Programming',22),
(2,'Web Design',18),
(3,'Database Management',23)
insert into Result (StudentId,SubjectId,Mark)
values
(1,1,8),
(1,2,7),
(2,3,5),
(3,2,6),
(4,3,9),
(5,2,8)
---query
SELECT StudentId as 'MãSinhViên', StudentName as 'TênSinhViên', BirthDate as 'ngay sinh'
FROM Student
WHERE BirthDate BETWEEN '1992-10-10' AND '1993-10-10';
-- đếm
select Class.ClassId 'MãLớp', Class.ClassCode 'TênLớp', count(Student.ClassId) 'si so lop'
from Student, Class
where Student.ClassId = Class.ClassId
group by Class.ClassId, Class.ClassCode
select Student.StudentId 'Mãsv', Student.StudentName 'Tênsv', sum(Result.Mark) 'tong diem'
from Student, Result
where Student.StudentId = Result.StudentId
group by Student.StudentId, Student.StudentName
having count(Result.Mark) >= 10
Nguyễn Minh Hiếu
2021-04-10 01:27:09
#QLSV.sql
create database QLSV
create table lop
(
classid int primary key not null,
classcode nvarchar(50)
)
create table hocsinh
(
studentid int primary key not null,
studentname nvarchar(50),
birthdate datetime,
classid int references lop(classid)
)
create table mon
(
subjectid int primary key not null,
subjectname nvarchar(100),
sessioncount int
)
create table ketqua
(
studentid int references hocsinh(studentid) not null,
subjectid int references mon(subjectid) not null,
mark int
)
alter table ketqua add constraint pk_studentid_subject_id primary key (studentid,subjectid)
alter table mon add constraint ck_sessioncount check(sessioncount>0)
insert into lop(classid,classcode)values
(1,'C1106KV'),
(2,'C1108GV'),
(3,'C1108IV'),
(4,'C1108HV'),
(5,'C1109GV')
insert into hocsinh(studentid,studentname,birthdate,classid) values
(1,N'Phạm Tuấn Anh','1993-08-05',1),
(2,N'Phạm Văn Huy','1992-06-10',1),
(3,N'Nguyễn Hoàng Minh','1992-09-07',2),
(4,N'Trần Tuấn Tú','1993-10-10',2),
(5,N'Đỗ Anh Tài','1992-06-06',3)
insert into mon(subjectid,subjectname,sessioncount) values
(1,'C programming',22),
(2,'Web Design',18),
(3,'Database Management',23)
insert into ketqua(studentid,subjectid,mark) values
(1,1,8),
(1,2,7),
(2,3,5),
(3,2,6),
(4,3,9),
(5,2,8)
select studentid,studentname,birthdate
from hocsinh
where hocsinh.birthdate between '1992-10-10' and '1993-10-10'
select lop.classid,classcode,COUNT(classcode) 'Sĩ số lớp'
from lop join hocsinh on lop.classid = hocsinh.classid
group by lop.classid,classcode
select hocsinh.studentid,studentname,Sum(mark) 'Tổng điểm'
from hocsinh join ketqua on hocsinh.studentid = ketqua.studentid
group by hocsinh.studentid,studentname
Đào Mạnh Dũng
2021-04-08 14:20:24
create database StudentManagementSystem
use StudentManagementSystem
create table Class (
ClassId int not null primary key identity(1,1),
ClassCode nvarchar(50)
)
create table Student (
StudentId int not null primary key identity(1,1),
StudentName nvarchar(50),
BirthDate datetime,
ClassId int foreign key references Class(ClassId),
)
create table Subject (
SubjectId int not null primary key identity(1,1),
SubjectName nvarchar(100),
SessionCount int,
constraint check_Cout check (SessionCount > 0 )
)
create table Result (
StudentId int references Student(StudentId),
SubjectId int references Subject(SubjectId),
Mark int,
primary key (StudentId,SubjectId)
)
drop table Result
drop table Student
drop table Subject
insert into Class (ClassCode)
values
('C1106KV'),
('C1108GV'),
('C1108IV'),
('C1108HV'),
('C1109GV')
insert into Student (StudentName,BirthDate,ClassId)
values
('Phạm Tuấn Anh','1993-08-05',1),
('Phan Văn Huy','1992-06-10',1),
('Nguyễn Hoàng Minh','1992-09-07',2),
('Trần Tuấn Tú','1993-10-10',2),
('Đỗ Anh Tài','1992-08-05',3)
insert into Subject (SubjectName,SessionCount)
values
('C Programming',22),
('Web Design',18),
('Database Management',23)
insert into Result (StudentId,SubjectId,Mark)
values
(1,1,8),
(1,2,7),
(2,3,5),
(3,2,6),
(4,3,9),
(5,2,8)
select Student.StudentId,Student.StudentName,Student.BirthDate from Student
where Student.BirthDate between '1992-10-10' and '1993-10-10'
Đào Mạnh Dũng
2021-04-08 13:18:53
create database StudentManagementSystem
use StudentManagementSystem
create table Class (
ClassId int not null primary key identity(1,1),
ClassCode nvarchar(50)
)
create table Student (
StudentId int not null primary key identity(1,1),
StudentName nvarchar(50),
BirthDate datetime,
ClassId int foreign key references Class(ClassId),
)
create table Subject (
SubjectId int not null primary key identity(1,1),
SubjectName nvarchar(100),
SessionCount int
)
drop table Result
create table Result (
StudentId int references Student(StudentId),
SubjectId int references Subject(SubjectId),
Mark int,
primary key (StudentId,SubjectId)
)
TRẦN VĂN ĐIỆP
2021-02-25 07:53:05
-- Tao database
create database StudentManagementSystem
-- Active database
use StudentManagementSystem
-- Create Tables
---- Table: Class
create table Class (
ClassId INT NOT NULL,
ClassCode NVARCHAR(50)
)
create table Student (
StudentId INT NOT NULL,
StudentName NVARCHAR(50),
BirthDate DATETIME,
ClassId INT
)
create table Subject (
SubjectId INT NOT NULL,
SubjectName NVARCHAR(100),
SessionCount Int
)
create table Result (
StudentId INT NOT NULL,
SubjectId INT NOT NULL,
Mark INT
)
-- Index
create nonclustered index NCI_Student_StudentName on Student(StudentName)
alter table Result
alter column Mark float
-- Item 4: Primary Key
alter table Class
add constraint PK_Class primary key (ClassId)
alter table Student
add constraint PK_Student primary key (StudentId)
alter table Subject
add constraint PK_Subject primary key (SubjectId)
alter table Result
add constraint PK_Result primary key (StudentId, SubjectId)
---- Foreign key
alter table Student
add constraint FK_Student_Class foreign key (ClassId) references Class(ClassId)
alter table Result
add constraint FK_Result_Student foreign key (StudentId) references Student(StudentId)
alter table Result
add constraint FK_Result_Subject foreign key (SubjectId) references Subject(SubjectId)
-- Check
alter table Subject
add constraint CK_Subject_SessionCount check (SessionCount> 0)
-- Insert Data
select * from Class
insert into Class(ClassId, ClassCode)
values
(1 ,'C1106KV'),
(2 ,'C1108GV'),
(3 ,'C1108IV'),
(4 ,'C1108HV'),
(5 ,'C1109GV')
insert into Student(StudentId, StudentName, BirthDate, ClassId)
values
(1, 'Phạm Tuấn Anh', '1993-08-05', 1),
(2, 'Phan Văn Huy', '1992-06-10', 1),
(3, 'Nguyễn Hoàng Minh', '1992-09-07', 2),
(4, 'Trần Tuấn Tú', '1993-10-10', 2),
(5, 'Đỗ Anh Tài', '1992-06-06', 3)
insert into Subject(SubjectId, SubjectName, SessionCount)
values
(1, 'C Programming', 22),
(2, 'Web Design', 18),
(3, 'Database Management', 23)
insert into Result(StudentId, SubjectId, Mark)
values
(1, 1, 8),
(1, 2, 7),
(2, 3, 5),
(3, 2, 6),
(4, 3, 9),
(5, 2, 8)
-- Query
select StudentId as 'Ma Sinh Vien', StudentName as 'Ten Sinh Vien', BirthDate as 'Ngay Sinh' from Student
where BirthDate between '1992-10-10' and '1993-10-10'
select Class.ClassId, Class.ClassCode, count(Student.StudentId) as TotalStudent
from Class left join Student on Class.ClassId = Student.ClassId
group by Class.ClassId, Class.ClassCode
select * from Student
select * from Subject
select * from Result
select Student.StudentId, Student.StudentName, sum(Result.Mark) as TotalMark
from Student left join Result on Student.StudentId = Result.StudentId
group by Student.StudentId, Student.StudentName
having sum(Result.Mark) > 10
-- View
create view view_StudentSubjectMark
as
select Student.StudentId, Student.StudentName, Subject.SubjectName, Result.Mark
from Student left join Result on Student.StudentId = Result.StudentId
left join Subject on Result.SubjectId = Subject.SubjectId
select top(3) * from view_StudentSubjectMark
order by Mark desc
-- Proc
create proc up_IncreaseMark
@SubjectId int
as
begin
update Result set Mark = Mark + 1 where SubjectId = @SubjectId
end
select * from Result where SubjectId = 2
exec up_IncreaseMark 2
-- trigger
create trigger TG_Result_Insert on Result
for insert
as
begin
if (select count(*) from inserted where Mark < 0) > 0
begin
print N'Can not insert mark < 0'
rollback transaction
end
end
insert into Result(StudentId, SubjectId, Mark)
values
(1, 3, -8)
create trigger TG_Subject_Update on Subject
for update
as
begin
if update(SubjectName)
begin
print N'You don"t update this column'
rollback transaction
end
end
select * from Subject
update Subject set SubjectName = 'AAA' where SubjectId = 1
Nguyễn Anh Vũ
2020-12-04 09:36:15
create database StudentManagementSystem
use StudentManagementSystem
create table Class (
ClassId int not null,
ClassCode nvarchar(70)
)
create table Student (
StudentId int not null,
StudentName nvarchar(50),
BirthDate datetime,
ClassId int
)
create table Subject (
SubjectId int not null,
SubjectName nvarchar(50),
SessionCount int
)
create table Result (
StudentId int not null,
SubjectId int not null,
Mark int
)
alter table Class
add constraint FK_Class primary key (ClassId)
alter table Student
add constraint FK_Student primary key (StudentId)
alter table Subject
add constraint FK_Subject primary key (SubjectId)
alter table Result
add constraint FK_Result primary key (StudentId,SubjectId)
alter table Student
add constraint FK_Student_Class foreign key (ClassId) references Class(ClassId)
alter table Result
add constraint FK_Result_Student foreign key (StudentId) references Student(StudentId)
alter table Result
add constraint FK_Result_Subject foreign key (SubjectId) references Subject(SubjectId)
alter table Subject
add check (Sessioncount > 0)
insert into Class(ClassId, ClassCode)
values
('1', 'C1106KV'),
('2', 'C1108GV'),
('3', 'C1108IV'),
('4', 'C1108HV'),
('5', 'C1109GV')
insert into Student(StudentId, StudentName, BirthDate, ClassId)
values
('1', 'Phạm Tuấn Anh', '1993-08-05 ', '1'),
('2', 'Phan Văn Huy', '1992-06-10', '1'),
('3', 'Nguyễn Hoàng Minh', '1992-09-07 ', '2'),
('4', 'Trần Tuấn Tú', '1993-10-10', '2'),
('5', 'Đỗ Anh Tài', '1992-06-06', '3')
insert into Subject(SubjectId, SubjectName, SessionCount)
values
('1', 'C Programming', '22'),
('2', 'Web Design', '18'),
('3', 'Database Management', '23')
insert into Result(StudentId, SubjectId, Mark)
values
('1', '1', 8),
('1', '2', 7),
('2', '3', 5),
('3', '2', 6),
('4', '3', 9),
('5', '2', 8)
select StudentId, StudentName, BirthDate
from Student
where BirthDate between '1992-10-10' and '1993-10-10'
select Class.ClassId, Class.ClassCode, COUNT(Student.StudentId) TotalStudent
from Class, Student
where Class.ClassId = Student.StudentId
group by Class.ClassId, Class.ClassCode
select Student.StudentId, Student.StudentName, SUM(Result.Mark) TotalMark
from Student left join Result on Student.StudentId = Result.StudentId
group by Student.StudentId, Student.StudentName
having SUM(Result.Mark) > 10
order by TotalMark desc
select * from Class
select * from Student
select * from Subject
select * from Result