ECNU数据库作业——Lab3

Lab 3

EX1

What are the names and release years for all the songs of the youngest singer?

SELECT singer.`Name` AS Singer_name, singer.Song_Name, singer.Song_release_year
FROM singer
WHERE singer.Age = (
	SELECT MIN(singer.Age)
	FROM singer
);
image-20231107110536353

EX2

List all song names by singers above the average age.

SELECT singer.Song_Name, singer.`Name`, singer.Age
FROM singer
WHERE singer.Age > (
	SELECT AVG(singer.Age)
	FROM singer
);
image-20231107110801981

EX3

Show the stadium name and the number of concerts in each stadium.

# 使用COALESCE()函数将没有匹配的空值设置为0,便于统计count
SELECT statium.Stadium_ID, stadium.`Name`, COALESCE(COUNT(c.Stadium_ID), 0) AS `number of concerts`
FROM stadium
# 使用左外连接
LEFT JOIN concert ON stadium.Stadium_ID = concert.Stadium_ID
GROUP BY stadium.Stadium_ID, stadium.`Name`
ORDER BY `number of concerts` DESC
image-20231107134958085

EX4

What is the name and capacity of the stadium with the most concerts after 2013 ?

SELECT stadium.`Name`, stadium.Capacity 
FROM stadium 
JOIN concert ON stadium.Stadium_ID = concert.Stadium_ID 
GROUP BY stadium.Stadium_ID 
HAVING COUNT(concert.Stadium_ID) = ( 
    # 筛选举办演唱会次数最多的场馆
	SELECT MAX(count_concerts) 
	FROM (
        # 统计场馆举办的演唱会次数
		SELECT COUNT(concert.Stadium_ID) AS count_concerts 
		FROM concert 
		WHERE concert.`Year` > 2013 
		GROUP BY concert.Stadium_ID 
	) AS subquery_maxCount
)
image-20231107131616239

EX5

Show names for all stadiums except for stadiums having a concert in year 2014.

SELECT stadium.`Name`
FROM stadium
# 左连接,并添加2014年的限定条件:可以实现将非2014年举办演唱会/没有举办过演唱会的场馆ID全部设置为NULL
LEFT JOIN concert ON concert.Stadium_ID = stadium.Stadium_ID AND concert.`Year` = 2014
WHERE concert.Stadium_ID IS NULL
image-20231107114639005

EX6

Find the female singers who have participated in the ‘Auditions’ concert but have not participated in the ‘Super bootcamp’ concert. Additionally, their song names should start with a vowel (A, E, I, O, U). Return the name of the singer, the name of the song, the year of the concert, and the name and location of the stadium where the concert was held. Also, sort the results in descending order by the year of the concert.

SELECT singer.`Name` AS singer_name, singer.Song_Name, concert.`Year`, stadium.`Name` AS stadium_name, stadium.Location
FROM singer
JOIN singer_in_concert ON singer_in_concert.Singer_ID = singer.Singer_ID
JOIN concert ON concert.concert_ID = singer_in_concert.concert_ID
JOIN stadium ON stadium.Stadium_ID = concert.Stadium_ID
WHERE (
    # 女性歌手
	singer.Is_male = 0 
    # 参加过'Auditions'演唱会
	AND concert.concert_Name = 'Auditions' 
    # 没参加过'Super bootcamp'演唱会,使用 NOT IN 筛选
	AND singer.Singer_ID NOT IN (
		SELECT singer.Singer_ID
		FROM singer
		JOIN singer_in_concert ON singer_in_concert.Singer_ID = singer.Singer_ID
		JOIN concert ON concert.concert_ID = singer_in_concert.concert_ID
		WHERE concert.concert_Name = 'Super bootcamp'
	)
    # 歌曲名称以元音开头
	AND singer.Song_Name REGEXP '^[AEIOU]'
)
ORDER BY concert.`Year` DESC
image-20231107133741729
  • 8
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
ECNU计科考研复试机试是上海东华大学计算机科学与技术专业硕士研究生复试环节的一部分。机试一般包括计算机基础知识测试、编程实践、算法设计与分析、数据结构、数据库等内容。 机试的目的是通过实际操作和任务完成,评估考生的计算机基础知识、编程能力和解决问题的能力。机试一般会提供一些实际问题,考生需要根据题目要求进行编程实现,并实现功能要求以及考察的相关知识点。机试的题目会有一定的难度,需要考生具备扎实的计算机基础知识和编程实践经验。 针对ECNU计科考研复试机试的准备,考生可以从以下几个方面进行: 1. 夯实计算机基础知识:系统复习计算机组成原理、操作系统、数据结构、数据库等相关课程的基础知识点,理解并掌握核心概念和原理。 2. 学习编程技巧:熟练掌握至少一种编程语言,例如C++、Java等,并了解常用的编程工具和调试技巧,提高编程能力。 3. 解题经验积累:多做一些编程题和算法题,提高解题能力和编程实践经验。可以通过参加一些线上或线下的编程竞赛来提升自己的算法和编程水平。 4. 多做模拟机试:通过模拟机试,熟悉机试的形式和题目类型,提前感受机试的压力和难度,并对自己的不足进行总结和改进。 总之,ECNU计科考研复试机试是对考生计算机基础知识和编程实践能力的综合考查,需要考生充分准备和深入理解相关知识点。只有全面提高自己的计算机科学水平,才能在机试中取得好成绩。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值