Re: [課業] 資料庫兩題

看板Examination作者 (開弓)時間12年前 (2013/06/11 08:06), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串1/1
以下我沒有自己建資料庫跑過 純粹就個人認知回答歐XD ※ 引述《Mayinggo (馬贏狗)》之銘言: : 1. A SQL SELECT statement contains a nested query in the WHERE clause,comparing : the value of an attribute to the values returned by the nested SELECT with an : IN predicate. Which of the following predicates can be used in that statement : instead of IN? : (A)=SOME (B)=ALL : (C)=ANY (D)=EVERY : 答案是C : 查了一下用法IN=ANY=SOME : 所以不選SOME的理由是 還是答案其實可以選 優先選 =any 可以複選的話我會把any 跟 some 都選起來 如果是sql 92標準的話,的確some 是可以的 但 =any 是通用的,算常識 如果你選some可能會有版本問題 不會在每個版本都正確.. 我猜應該是這樣。 : 2. Two tables are given: STUDENT(StudNO,Name,Department) and GRADES(StudNo, : Course,Grade). Which of the given SQL statements will retrieve the names : of : students who got an A in each course they passed? : (A) SELECT name : FROM student : WHERE NOT EXISTS(SELECT * : FROM grades : WHERE grade IN('B','C')and : student.studno=grades.studno); : (B) SELECT name : FROM student JOIN grades ON student.studno=grades.studno : WHERE grade='A'; : (C) SELECT name : FROM student,grades : WHERE grade='A'and student.studno=grades.studno; : (D) SELECT name : FROM student : WHERE 'A'=ALL(SELECT grade : FROM grades : WHERE student.studno=grades.studno); : 已知題目沒有提到等第有哪些 所以不考慮A : 由於grades的屬性沒有name 所以C也不考慮 : B跟D不知道差在哪 答案是D 可是不知道B錯在哪 把B改一下變成 select name from student, grades where student.studno=grades.studno and grade='A' B很明顯錯了 這樣選應該只會跑出「得到A的學生」 而不是跑出「每一科都用A passed 的學生」 如果你選D,那會選出每一科成績都等於A的學生 只有差在這裡 題意條件是 retrieve the names of students who got an A in each course they passed? 應該是這樣吧我想... 順便說... 選項C我看一下,運算結果大概跟B一樣。 這跟grades table裡面有沒有name屬性沒關係 使用table_name.column_name 來呼叫特定行這種寫法 只有在join 的tables裡面有一樣的column命名時才需要特別標明 其他時候不需要... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 175.111.51.2 ※ 編輯: ARCHERDEVIL 來自: 175.111.51.2 (06/11 09:15)

06/11 14:15, , 1F
好難的題目....請問這些題目是去哪裡找到的呢?
06/11 14:15, 1F

06/11 15:05, , 2F
看原PO寫好像是某年雲科大碩班資管所考題?
06/11 15:05, 2F
文章代碼(AID): #1HjcdutF (Examination)