早教吧作业答案频道 -->英语-->
请问如何用SQLHotel(hotelNo,hotelName,hotelAddress)Room(hotelNo,roomNo,type,price)Guest(guestNo,guestName,guestAddress)Booking(hotelNo,guestNo,dateFrom,dateTo,roomNo)1)Howmanyhotelsarethere?2)Whatistheaveragepriceofaroom?3)What
题目详情
请问如何用SQL
Hotel (hotelNo,hotelName,hotelAddress)
Room (hotelNo,roomNo,type,price)
Guest (guestNo,guestName,guestAddress)
Booking (hotelNo,guestNo,dateFrom,dateTo,roomNo)
1) How many hotels are there?
2) What is the average price of a room?
3) What is the total revenue per night from all double rooms?
4) How many different guests have future bookings in each hotel?
5) List all guests who are currently staying in hotelNo 1.
6) List the number of rooms in each hotel.
7) What is the minimum and maximum price of rooms in each hotel?
8) What is the maximum possible daily revenue for each room size for each hotel?
1.一共多少酒店?
2.房间平均价格是多少?
3.双人房一晚的总共收入是多少?
4.有多少客人预定了酒店?
5.列出一共有多少客人正在hotelNo1.
6.列出每个酒店的房间号码.
7.每个酒店最高和最低价格是多少?
8.每个酒店每种房间一天最高收入是多少?
Hotel (hotelNo,hotelName,hotelAddress)
Room (hotelNo,roomNo,type,price)
Guest (guestNo,guestName,guestAddress)
Booking (hotelNo,guestNo,dateFrom,dateTo,roomNo)
1) How many hotels are there?
2) What is the average price of a room?
3) What is the total revenue per night from all double rooms?
4) How many different guests have future bookings in each hotel?
5) List all guests who are currently staying in hotelNo 1.
6) List the number of rooms in each hotel.
7) What is the minimum and maximum price of rooms in each hotel?
8) What is the maximum possible daily revenue for each room size for each hotel?
1.一共多少酒店?
2.房间平均价格是多少?
3.双人房一晚的总共收入是多少?
4.有多少客人预定了酒店?
5.列出一共有多少客人正在hotelNo1.
6.列出每个酒店的房间号码.
7.每个酒店最高和最低价格是多少?
8.每个酒店每种房间一天最高收入是多少?
▼优质解答
答案和解析
SQL时间我都忘了,呵呵,时间函数就用Oracle替换了,答题的时候加以说明就行,没问题的.
1) How many hotels are there?那里有多少家宾馆?
2) What is the average price of a room?一间房的平均价格是多少?
3) What is the total revenue per night from all double rooms?所有双人间每晚的总收入是多少?
4) How many different guests have future bookings in each hotel?每家宾馆里有多少客人预定了房间?
5) List all guests who are currently staying in hotelNo 1.罗列目前入住第一宾馆的客人
6) List the number of rooms in each hotel.罗列每家宾馆的房间数
7) What is the minimum and maximum price of rooms in each hotel?每家宾馆的最高和最低房价是多少?
8) What is the maximum possible daily revenue for each room size for each hotel?每家宾馆中每种类型的房间最高日收入是多少?
翻译的差别让结果差很多.
1.select count(*) from Hotel
2.select avg(price) from Room r(跟哪家宾馆没关系,题目没要求)
3.需要提供晚间的时间段,假设是晚8点-早8点
select count(r.price) from Room r
where r.type='double rooms'
and exists
(
select b.roomNo from Booking b
where b.roomNo=r.roomNo
and to_number(to_char(b.dateTo,'hh')) < 8
and to_number(to_char(b.dateFrom,'hh')) > 20
)
4.预定就是没入住,入住时间>当前时间
select count(b.guestNo) from Booking b
group by b.hotelNo
having b.dateFrom > sysdate
5.退房时间>当前时间,就是没退房正在居住的
select g.* from Guest g
where g.guestNo in
(
select b.guestNo from Booking b
where b.hotelNo=1
and b.dateTo > sysdate
)
6.select r.hotelNo,count(r.roomNo) from Room r
group by r.hotelNo
7.select r.hotelNo,max(r.price),min(r.price) from Room r
group by r.hotelNo
8.price单位是多少?一天还是一小时?假设是一天.
select count(r.roomNo)*r.price from Room r
group by r.hotelNo,r.type
1) How many hotels are there?那里有多少家宾馆?
2) What is the average price of a room?一间房的平均价格是多少?
3) What is the total revenue per night from all double rooms?所有双人间每晚的总收入是多少?
4) How many different guests have future bookings in each hotel?每家宾馆里有多少客人预定了房间?
5) List all guests who are currently staying in hotelNo 1.罗列目前入住第一宾馆的客人
6) List the number of rooms in each hotel.罗列每家宾馆的房间数
7) What is the minimum and maximum price of rooms in each hotel?每家宾馆的最高和最低房价是多少?
8) What is the maximum possible daily revenue for each room size for each hotel?每家宾馆中每种类型的房间最高日收入是多少?
翻译的差别让结果差很多.
1.select count(*) from Hotel
2.select avg(price) from Room r(跟哪家宾馆没关系,题目没要求)
3.需要提供晚间的时间段,假设是晚8点-早8点
select count(r.price) from Room r
where r.type='double rooms'
and exists
(
select b.roomNo from Booking b
where b.roomNo=r.roomNo
and to_number(to_char(b.dateTo,'hh')) < 8
and to_number(to_char(b.dateFrom,'hh')) > 20
)
4.预定就是没入住,入住时间>当前时间
select count(b.guestNo) from Booking b
group by b.hotelNo
having b.dateFrom > sysdate
5.退房时间>当前时间,就是没退房正在居住的
select g.* from Guest g
where g.guestNo in
(
select b.guestNo from Booking b
where b.hotelNo=1
and b.dateTo > sysdate
)
6.select r.hotelNo,count(r.roomNo) from Room r
group by r.hotelNo
7.select r.hotelNo,max(r.price),min(r.price) from Room r
group by r.hotelNo
8.price单位是多少?一天还是一小时?假设是一天.
select count(r.roomNo)*r.price from Room r
group by r.hotelNo,r.type
看了 请问如何用SQLHotel(...的网友还看了以下:
个关于数学里直线方程式的问题-.1.求过点P,且平行于直线L的直线方程(1)P(5.2)L:3X- 2020-06-03 …
近代化学基础急一1.在用量子数表示核外电子运动状态时,写出下列各组中所缺少的量子数.(1)n=3, 2020-06-04 …
已知圆C:(x-3)^2+(y-4)^2=4,直线L过定点A(1,0)1.若L与圆相切,求L的方程 2020-06-27 …
下列原电池中,电动势最大的是:A,(-)Zn/Zn^2+(1mol/L)//Ag+(1mol/L) 2020-07-01 …
请高手用MATLAB帮忙解下微分方程组教下:Dy(1)=y(2);Dy(2)=y(3)^2*u*A 2020-07-21 …
想在matlab里面实现,已知S和R的关系,见'补充'.L已知,S自变量,R因变量,想根据S的值计 2020-08-01 …
定积分计算∫l/(d^2/4+l^2)^(3/2)*dl在[0,l]上的积分能计算吗?d是常数∫L 2020-08-02 …
过点P(-3,-4)作直线l,当l的斜率为何值时(1)l将圆(x-1)^2+(y+2)^2=4平分? 2020-10-30 …
两种金属的密度分别为ρl,ρ2,且ρl:ρ2=2:1,它们的比热分别为cl,c2,且cl:c2=1: 2020-10-31 …
matlab中的fmincon函数请帮忙看下这段程序哪里出错了运行不出来functionf=myfu 2020-12-08 …