0% found this document useful (0 votes)
15 views1 page

SQL Database Creation for Students and Faculty

Uploaded by

phuthopt29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views1 page

SQL Database Creation for Students and Faculty

Uploaded by

phuthopt29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

use master

CREATE DATABASE SINHVIEN;


GO

USE SINHVIEN;
GO

CREATE TABLE Khoa (


Makhoa CHAR(10) PRIMARY KEY,
Tenkhoa CHAR(30),
Dienthoai CHAR(10)
);
GO

CREATE TABLE GiangVien (


MaGV INT PRIMARY KEY,
HotenGV CHAR(30),
Luong DECIMAL(10, 2),
Makhoa CHAR(10),
FOREIGN KEY (Makhoa) REFERENCES Khoa(Makhoa)
);
GO

CREATE TABLE SinhVien (


MaSV INT PRIMARY KEY,
HotenSV CHAR(30),
Makhoa CHAR(10),
Namsinh INT,
Quequan CHAR(30),
FOREIGN KEY (Makhoa) REFERENCES Khoa(Makhoa)
);
GO

select * from SinhVien

select * from SinhVien where (YEAR(GETDATE())-YEAR(Namsinh))>=20;

select * from SinhVien where HotenSV like N'Nguyễ


n';

select distinct Quequan from SinhVien;

select * from GiangVien where (Luong>=10000000) and (Luong<=20000000)

select * from SinhVien


order by Namsinh ASC

select top 2 * from SinhVien


order by Namsinh ASC

select top 30 percent from GiangVien


order by Luong DESC

select * from SinhVien where Quequan not in (N'Hà Nội',N'Bắ


c
giang',N'Lạng Sơn')

select top 2 * from GiangVien


order by Luong ASC

You might also like