Đăng Nhập
Latest topics
Ai cần Bài LAB 4 liên hệ
2 posters
Trang 1 trong tổng số 1 trang
Bonstar- Khỉ Trưởng Lão
- Tổng số bài gửi : 80
Join date : 15/09/2010
Age : 32
Đến từ : Tp.HCM
Re: Ai cần Bài LAB 4 liên hệ
Đây là bài World Class Travel
--Tao db World Class Travel and Tours
create database WCTT
go
use WCTT
go
--Tao table ten Flights
create table [Flights]
(
AircraftCode nvarchar(10) primary key,
Ftype nvarchar(10),
[Source] nvarchar(20),
Destination nvarchar(20),
DepTime datetime,
JourneyHrs int
)
GO
--Chen du lieu vao table Flights
Insert into Flights(AircraftCode,FType,[Source],Destination,Deptime,JourneyHrs)
values('UA01','Boeing','Los Angeles','London','15:30',6)
Insert into Flights(AircraftCode,FType,[Source],Destination,Deptime,JourneyHrs)
values('UA02','Boeing','California','New York','9:30',
Insert into Flights(AircraftCode,FType,[Source],Destination,Deptime,JourneyHrs)
values('SA01','Boeing','Istanbul','Ankara','10:45',
Insert into Flights(AircraftCode,FType,[Source],Destination,Deptime,JourneyHrs)
values('SA02','Airbus','London','Moscow','11:15',9)
Insert into Flights(AircraftCode,FType,[Source],Destination,Deptime,JourneyHrs)
values('SQ01','Airbus','Sydney','Ankara','01:45',15)
Insert into Flights(AircraftCode,FType,[Source],Destination,Deptime,JourneyHrs)
values('SQ02','Boeing','Perth','Aden','13:30',10)
Insert into Flights(AircraftCode,FType,[Source],Destination,Deptime,JourneyHrs)
values('SQ03','Airbus','San Francisco','Nairobi','15:45',15)
--Hien thi thong tin trong bang Flights
select *from Flights
go
--Hien thi thong tin AirCraftCode, Source, Destination, Deptime
Select AirCraftCode, [Source], Destination, Deptime from Flights
--Them thong tin vao table giong table ban dau
insert into Flights (AircraftCode,Ftype,[Source],Destination,DepTime,JourneyHrs)
values('UA03','Boeing','Los Angeles','London','15:30',6)
go
--Hien thi top 65%
Select top (65) percent* from Flights
go
--Hien thi 2 record dau tien
Select top (2) * from Flights
go
--Tong so chuyen bay
Select COUNT (AirCraftCode) as TongChuyenBay
from Flights
--So tien chi tra
Select *, JourneyHrs*150 as Tientra
From Flights
--Tao db World Class Travel and Tours
create database WCTT
go
use WCTT
go
--Tao table ten Flights
create table [Flights]
(
AircraftCode nvarchar(10) primary key,
Ftype nvarchar(10),
[Source] nvarchar(20),
Destination nvarchar(20),
DepTime datetime,
JourneyHrs int
)
GO
--Chen du lieu vao table Flights
Insert into Flights(AircraftCode,FType,[Source],Destination,Deptime,JourneyHrs)
values('UA01','Boeing','Los Angeles','London','15:30',6)
Insert into Flights(AircraftCode,FType,[Source],Destination,Deptime,JourneyHrs)
values('UA02','Boeing','California','New York','9:30',
Insert into Flights(AircraftCode,FType,[Source],Destination,Deptime,JourneyHrs)
values('SA01','Boeing','Istanbul','Ankara','10:45',
Insert into Flights(AircraftCode,FType,[Source],Destination,Deptime,JourneyHrs)
values('SA02','Airbus','London','Moscow','11:15',9)
Insert into Flights(AircraftCode,FType,[Source],Destination,Deptime,JourneyHrs)
values('SQ01','Airbus','Sydney','Ankara','01:45',15)
Insert into Flights(AircraftCode,FType,[Source],Destination,Deptime,JourneyHrs)
values('SQ02','Boeing','Perth','Aden','13:30',10)
Insert into Flights(AircraftCode,FType,[Source],Destination,Deptime,JourneyHrs)
values('SQ03','Airbus','San Francisco','Nairobi','15:45',15)
--Hien thi thong tin trong bang Flights
select *from Flights
go
--Hien thi thong tin AirCraftCode, Source, Destination, Deptime
Select AirCraftCode, [Source], Destination, Deptime from Flights
--Them thong tin vao table giong table ban dau
insert into Flights (AircraftCode,Ftype,[Source],Destination,DepTime,JourneyHrs)
values('UA03','Boeing','Los Angeles','London','15:30',6)
go
--Hien thi top 65%
Select top (65) percent* from Flights
go
--Hien thi 2 record dau tien
Select top (2) * from Flights
go
--Tong so chuyen bay
Select COUNT (AirCraftCode) as TongChuyenBay
from Flights
--So tien chi tra
Select *, JourneyHrs*150 as Tientra
From Flights
Bonstar- Khỉ Trưởng Lão
- Tổng số bài gửi : 80
Join date : 15/09/2010
Age : 32
Đến từ : Tp.HCM
Re: Ai cần Bài LAB 4 liên hệ
Đây là bài Passenger
/*LAB4 trang 151*/
create database PASS
go
Use PASS
go
/*Create Passenger table*/
Create table passengers
(
PNRNo int not null,
TicketNo int not null,
PassName nvarchar (25) not null,
Age int not null,
Sex char (6)not null,
)
go
/*Insert the following details in the Passenger table*/
insert into passengers(PNRNo,TicketNo,PassName,Age,Sex)
values (1,1,'Allan Smith',45,'Male')
insert into passengers(PNRNo,TicketNo,PassName,Age,Sex)
values (1,2,'Stella Smith',23,'Female')
insert into passengers(PNRNo,TicketNo,PassName,Age,Sex)
values (1,3,'Pamella Smith',26,'Female')
insert into passengers(PNRNo,TicketNo,PassName,Age,Sex)
values (2,4,'Peter Jones',27,'Male')
insert into passengers(PNRNo,TicketNo,PassName,Age,Sex)
values (2,5,'Stefa Jones',30,'Female')
insert into passengers(PNRNo,TicketNo,PassName,Age,Sex)
values (3,6,'Alex Lee',22,'Male')
insert into passengers(PNRNo,TicketNo,PassName,Age,Sex)
values (3,7,'Greta Lee',20,'Female')
insert into passengers(PNRNo,TicketNo,PassName,Age,Sex)
values (3,8,'Steve Wilson',28,'Male')
go
/*Display PassName,Age and Sex*/
select PassName,Age,Sex from passengers
go
/*Insert record whose details match those of 'Stefa Jones'*/
insert into passengers
values (2,5,'Britney Spear',30,'Female')
go
/*Display only those records such that duplicate records do not appear*/
select distinct * from passengers
go
/*Display the total number of passenger*/
select COUNT (TicketNo)as TotalNumber from passengers
go
/*Display the average age of the passenger from the Passenger table*/
select AVG(Age) as AverageAge from passengers
go
/*Display the Top 3 records by declaring an integer variable and using it with the Top clause*/
select top 3 (TicketNo)from passengers
go
declare @abc int
set @abc=3
select top (@abc) * from passengers
go
/* Create a table NewPassenger with the same structure as the Passenger table*/
create table NewPassenger
(
PNRNo int not null,
TicketNo int not null,
PassName nvarchar (25) not null,
Age int not null,
Sex char (6)not null,
)
go
insert into NewPassenger(PNRNo,TicketNo,PassName,Age,Sex)
values (1,1,'Allan Smith',45,'Male')
insert into NewPassenger(PNRNo,TicketNo,PassName,Age,Sex)
values (1,2,'Stella Smith',23,'Female')
insert into NewPassenger(PNRNo,TicketNo,PassName,Age,Sex)
values (1,3,'Pamella Smith',26,'Female')
go
/*LAB4 trang 151*/
create database PASS
go
Use PASS
go
/*Create Passenger table*/
Create table passengers
(
PNRNo int not null,
TicketNo int not null,
PassName nvarchar (25) not null,
Age int not null,
Sex char (6)not null,
)
go
/*Insert the following details in the Passenger table*/
insert into passengers(PNRNo,TicketNo,PassName,Age,Sex)
values (1,1,'Allan Smith',45,'Male')
insert into passengers(PNRNo,TicketNo,PassName,Age,Sex)
values (1,2,'Stella Smith',23,'Female')
insert into passengers(PNRNo,TicketNo,PassName,Age,Sex)
values (1,3,'Pamella Smith',26,'Female')
insert into passengers(PNRNo,TicketNo,PassName,Age,Sex)
values (2,4,'Peter Jones',27,'Male')
insert into passengers(PNRNo,TicketNo,PassName,Age,Sex)
values (2,5,'Stefa Jones',30,'Female')
insert into passengers(PNRNo,TicketNo,PassName,Age,Sex)
values (3,6,'Alex Lee',22,'Male')
insert into passengers(PNRNo,TicketNo,PassName,Age,Sex)
values (3,7,'Greta Lee',20,'Female')
insert into passengers(PNRNo,TicketNo,PassName,Age,Sex)
values (3,8,'Steve Wilson',28,'Male')
go
/*Display PassName,Age and Sex*/
select PassName,Age,Sex from passengers
go
/*Insert record whose details match those of 'Stefa Jones'*/
insert into passengers
values (2,5,'Britney Spear',30,'Female')
go
/*Display only those records such that duplicate records do not appear*/
select distinct * from passengers
go
/*Display the total number of passenger*/
select COUNT (TicketNo)as TotalNumber from passengers
go
/*Display the average age of the passenger from the Passenger table*/
select AVG(Age) as AverageAge from passengers
go
/*Display the Top 3 records by declaring an integer variable and using it with the Top clause*/
select top 3 (TicketNo)from passengers
go
declare @abc int
set @abc=3
select top (@abc) * from passengers
go
/* Create a table NewPassenger with the same structure as the Passenger table*/
create table NewPassenger
(
PNRNo int not null,
TicketNo int not null,
PassName nvarchar (25) not null,
Age int not null,
Sex char (6)not null,
)
go
insert into NewPassenger(PNRNo,TicketNo,PassName,Age,Sex)
values (1,1,'Allan Smith',45,'Male')
insert into NewPassenger(PNRNo,TicketNo,PassName,Age,Sex)
values (1,2,'Stella Smith',23,'Female')
insert into NewPassenger(PNRNo,TicketNo,PassName,Age,Sex)
values (1,3,'Pamella Smith',26,'Female')
go
Bonstar- Khỉ Trưởng Lão
- Tổng số bài gửi : 80
Join date : 15/09/2010
Age : 32
Đến từ : Tp.HCM
Re: Ai cần Bài LAB 4 liên hệ
Đây là bài Reservation
--Lab4 trang 152 RDBMS
create database NewPass
go
use NewPass
go
--create a Reservation table containing the following structure
Create table [Reservation]
(
PNRNo int not null,
AircraftCode nvarchar(10) not null,
JourneyDt datetime not null,
NoOfSeats int not null,
[Address] nvarchar(50) not null,
ContactNo bigint not null,
[Status] char (02)
)
go
--Insert Data
Insert into Reservation(PNRNo ,AircraftCode ,JourneyDt ,NoOfSeats ,[Address] ,ContactNo ,[Status] )
Values(1,'IA01','11-Nov-2006',2,'Newyork',9154896322,'C'),
(2,'9W01','15-Nov-2006',3,'London',9155659891,'C'),
(3,'IA01','11-Dec-2006',4,'Sydney',9147812569,'C'),
(4,'9W02','21-Dec-2006',2,'London',9165894752,'R'),
(5,'BA01','22-Dec-2006',1,'Perth',9135627489,'C')
go
--Display AircraftCode And JourneyDt
Select AircraftCode, JourneyDt from Reservation
go
--Display the total number of seats from the Reservation
Select SUM (NoOfSeats) as totalseats from Reservation
go
--Create a table named NewReservation having the same structure as the Reservation table
Create table [NewReservation]
(
PNRNo int,
AircraftCode nvarchar(10),
JourneyDt datetime,
NoOfSeats int,
[Address] nvarchar(50),
ContactNo bigint,
[Status] char (02)
)
go
--Use the INSERT WITH clause to insert values from the Reservation table into the NewReseervation table
Insert into NewReservation(PNRNo ,AircraftCode ,JourneyDt ,NoOfSeats ,[Address] ,ContactNo ,[Status] )
Values(1,'IA01','11-Nov-2006',2,'Newyork',9154896322,'C'),
(2,'9W01','15-Nov-2006',3,'London',9155659891,'C'),
(3,'IA01','11-Dec-2006',4,'Sydney',9147812569,'C'),
(4,'9W02','21-Dec-2006',2,'London',9165894752,'R'),
(5,'BA01','22-Dec-2006',1,'Perth',9135627489,'C');
with Reservation(PNRNo ,AircraftCode ,JourneyDt ,NoOfSeats ,[Address] ,ContactNo ,[Status] )
as
(
select *from NewReservation
)
insert into Reservation
select * from Reservation
go
--Modify the Reservation table and add a column'PassName' ...
alter table Reservation
add PassName varchar (25)
go
--Modify the Reservation table and make PNRNo as the Primary Key
alter table Reservation
add primary key (PNRNo)
go
--Lab4 trang 152 RDBMS
create database NewPass
go
use NewPass
go
--create a Reservation table containing the following structure
Create table [Reservation]
(
PNRNo int not null,
AircraftCode nvarchar(10) not null,
JourneyDt datetime not null,
NoOfSeats int not null,
[Address] nvarchar(50) not null,
ContactNo bigint not null,
[Status] char (02)
)
go
--Insert Data
Insert into Reservation(PNRNo ,AircraftCode ,JourneyDt ,NoOfSeats ,[Address] ,ContactNo ,[Status] )
Values(1,'IA01','11-Nov-2006',2,'Newyork',9154896322,'C'),
(2,'9W01','15-Nov-2006',3,'London',9155659891,'C'),
(3,'IA01','11-Dec-2006',4,'Sydney',9147812569,'C'),
(4,'9W02','21-Dec-2006',2,'London',9165894752,'R'),
(5,'BA01','22-Dec-2006',1,'Perth',9135627489,'C')
go
--Display AircraftCode And JourneyDt
Select AircraftCode, JourneyDt from Reservation
go
--Display the total number of seats from the Reservation
Select SUM (NoOfSeats) as totalseats from Reservation
go
--Create a table named NewReservation having the same structure as the Reservation table
Create table [NewReservation]
(
PNRNo int,
AircraftCode nvarchar(10),
JourneyDt datetime,
NoOfSeats int,
[Address] nvarchar(50),
ContactNo bigint,
[Status] char (02)
)
go
--Use the INSERT WITH clause to insert values from the Reservation table into the NewReseervation table
Insert into NewReservation(PNRNo ,AircraftCode ,JourneyDt ,NoOfSeats ,[Address] ,ContactNo ,[Status] )
Values(1,'IA01','11-Nov-2006',2,'Newyork',9154896322,'C'),
(2,'9W01','15-Nov-2006',3,'London',9155659891,'C'),
(3,'IA01','11-Dec-2006',4,'Sydney',9147812569,'C'),
(4,'9W02','21-Dec-2006',2,'London',9165894752,'R'),
(5,'BA01','22-Dec-2006',1,'Perth',9135627489,'C');
with Reservation(PNRNo ,AircraftCode ,JourneyDt ,NoOfSeats ,[Address] ,ContactNo ,[Status] )
as
(
select *from NewReservation
)
insert into Reservation
select * from Reservation
go
--Modify the Reservation table and add a column'PassName' ...
alter table Reservation
add PassName varchar (25)
go
--Modify the Reservation table and make PNRNo as the Primary Key
alter table Reservation
add primary key (PNRNo)
go
Bonstar- Khỉ Trưởng Lão
- Tổng số bài gửi : 80
Join date : 15/09/2010
Age : 32
Đến từ : Tp.HCM
Re: Ai cần Bài LAB 4 liên hệ
không bấm thank là ăn dép
Bonstar- Khỉ Trưởng Lão
- Tổng số bài gửi : 80
Join date : 15/09/2010
Age : 32
Đến từ : Tp.HCM
Re: Ai cần Bài LAB 4 liên hệ
có thấy nút thank ở chổ nào đâu mà bấm (30 char )
ananh- Khỉ Trưởng Lão
- Tổng số bài gửi : 34
Join date : 23/09/2010
Đến từ : Nhà người ta..
Trang 1 trong tổng số 1 trang
Permissions in this forum:
Bạn không có quyền trả lời bài viết
|
|
Mon Dec 02, 2013 6:22 pm by hoangthai0302
» [Tham khảo] Đề thi BDW FPT
Wed Aug 14, 2013 8:08 pm by yowisu
» Nhận giúp làm đồ án, project cuối kỳ, bài tập lớn cho sinh viên học lập trình dotNet tại Hà Nội
Mon Jul 08, 2013 11:44 am by aiglevnpro
» Đây là tài liệu học RDBMS mời download
Fri Nov 09, 2012 9:51 am by laiconghung
» [Tham Khảo] Ass 4 của tui :)
Fri Oct 26, 2012 10:21 pm by dat21892
» Giới thiệu Đại học FPT-Greenwich
Thu Oct 11, 2012 2:02 pm by comnhom.it
» De Ly Thuyet 134 cau day. Chuan luon do cua aptech nha
Tue Jun 26, 2012 10:33 pm by PhucBach
» THÔNG BÁO CƠ HỘI NGHỀ NGHIỆP
Tue Jun 05, 2012 10:48 am by yenns
» Khóa học miễn phí thiết kế diễn đàn bằng Vbulletin tại ICODE
Tue May 01, 2012 12:15 pm by mr_icode