日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

大连理工大学软件学院·数据库实验

發(fā)布時(shí)間:2024/1/1 数据库 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 大连理工大学软件学院·数据库实验 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
  • Find the ID, names of all the students from departments whose name contain character ‘功’.
mysql> select id, name, dept_name from student where dept_name like '%功%'; +-------+--------+-----------+ | id | name | dept_name | +-------+--------+-----------+ | 00128 | 丘處機(jī) | 內(nèi)功學(xué)院 | | 12345 | 段譽(yù) | 內(nèi)功學(xué)院 | | 54321 | 楊過 | 內(nèi)功學(xué)院 | | 76543 | 段正淳 | 內(nèi)功學(xué)院 | +-------+--------+-----------+ 4 rows in set
  • Find the ID, names and total credits of students in 邪門學(xué)院 department or in 兵器學(xué)院 department whose total credits are higher than 50 credits.
//AND和OR的優(yōu)先級(jí):AND > OR, 去掉括號(hào)結(jié)果錯(cuò)誤!!! mysql> select id, name, tot_cred,dept_name-> from student-> where (dept_name='邪門學(xué)院' or dept_name='兵器學(xué)院') and tot_cred>50; +-------+--------+----------+-----------+ | id | name | tot_cred | dept_name | +-------+--------+----------+-----------+ | 19991 | 林平之 | 80 | 兵器學(xué)院 | | 23121 | 穆念慈 | 110 | 兵器學(xué)院 | | 44553 | 藍(lán)鳳凰 | 56 | 邪門學(xué)院 | | 76653 | 胡斐 | 60 | 兵器學(xué)院 | | 98765 | 李莫愁 | 98 | 兵器學(xué)院 | +-------+--------+----------+-----------+ 5 rows in set
  • For the instructor 83821, show course_id and title of all courses taught by the instructor.
mysql> select course.course_id, title, sec_id-> from course, teaches-> where course.course_id = teaches.course_id and id='83821'; +-----------+----------+--------+ | course_id | title | sec_id | +-----------+----------+--------+ | cn2 | 九陰真經(jīng) | 1 | | cn2 | 九陰真經(jīng) | 2 | | cn4 | 易筋經(jīng) | 2 | +-----------+----------+--------+ 3 rows in set
  • As above, but show the total number of credits for such courses (taught by that instructor). You should use SQL aggregation on courses taught by that instructor.
mysql> select course.course_id, title, sum(credits)-> from course, teaches-> where course.course_id=teaches.course_id and id='83821'-> group by course.course_id, title; +-----------+----------+--------------+ | course_id | title | sum(credits) | +-----------+----------+--------------+ | cn2 | 九陰真經(jīng) | 8 | | cn4 | 易筋經(jīng) | 3 | +-----------+----------+--------------+ 2 rows in set
  • As above, but display the total credits for each of the instructors, along with the ID of the instructor; don’t bother about the name of the instructors. (Don’t bother about instructors who have not taught any course, they can be omitted)
mysql> select id, sum(credits)-> from teaches, course-> where course.course_id=teaches.course_id-> group by id; +-------+--------------+ | id | sum(credits) | +-------+--------------+ | 10101 | 10 | | 12121 | 3 | | 15151 | 3 | | 22222 | 4 | | 32343 | 3 | | 45565 | 7 | | 76766 | 8 | | 83821 | 11 | | 98345 | 3 | +-------+--------------+ 9 rows in set
  • Find average instructors’ salaries for each of courses, along with the course_id and title of the course, taught by instructors of 內(nèi)功學(xué)院, the result should be sorted from the lowest to the highest according to the average salaries.
mysql> select course.course_id, title, avg(salary)-> from course, instructor, teaches-> where instructor.id=teaches.id and teaches.course_id=course.course_id and instructor.dept_name='內(nèi)功學(xué)院'-> group by course.course_id, title-> order by avg(salary); +-----------+----------+-------------+ | course_id | title | avg(salary) | +-----------+----------+-------------+ | cn5 | 太極 | 65000 | | cn3 | 九陽神功 | 65000 | | cn1 | 內(nèi)功基礎(chǔ) | 70000 | | cn4 | 易筋經(jīng) | 83500 | | cn2 | 九陰真經(jīng) | 92000 | +-----------+----------+-------------+ 5 rows in set
  • Find the names of all courses which have been taught in 南疆雨林 ever. (there should be no duplicate names)
mysql> select distinct title-> from course, section-> where course.course_id=section.course_id and building='南疆雨林'; +----------+ | title | +----------+ | 槍法 | | 內(nèi)功基礎(chǔ) | | 坑蒙拐騙 | +----------+ 3 rows in set
  • Display the IDs and names of all students who have never registered for a course.
mysql> select id, name-> from student-> where tot_cred=0; +-------+------+ | id | name | +-------+------+ | 70557 | 楊康 | +-------+------+ 1 row in set
  • Find the id and names of the courses which have been registered by some students without evaluated grade.
mysql> select course.course_id, title, grade-> from course, takes-> where course.course_id=takes.course_id and grade is null; +-----------+-------+-------+ | course_id | title | grade | +-----------+-------+-------+ | cq2 | 散打 | NULL | +-----------+-------+-------+ 1 row in set
  • Find the courses which are the Subsequence courses of other courses. The result should involve the ids and titles of the Subsequence courses and the ids and titles of its prerequisites. (note: the names of columns in result should show the roles of the courses clearly)
mysql> select a.course_id, a.title SUB, b.course_id, b.title PRE-> from course a, course b, prereq-> where a.course_id=prereq.course_id and b.course_id=prereq.prereq_id; +-----------+----------+-----------+----------+ | course_id | SUB | course_id | PRE | +-----------+----------+-----------+----------+ | cn2 | 九陰真經(jīng) | cn1 | 內(nèi)功基礎(chǔ) | | cn3 | 九陽神功 | cn1 | 內(nèi)功基礎(chǔ) | | cn4 | 易筋經(jīng) | cn1 | 內(nèi)功基礎(chǔ) | | cn5 | 太極 | cn1 | 內(nèi)功基礎(chǔ) | | cq2 | 散打 | cq1 | 少林長(zhǎng)拳 | | cq3 | 自由搏擊 | cq1 | 少林長(zhǎng)拳 | +-----------+----------+-----------+----------+ 6 rows in set

總結(jié)

以上是生活随笔為你收集整理的大连理工大学软件学院·数据库实验的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。