資料庫 - 考試
By Skylar Davis
at 2014-04-03T16:21
at 2014-04-03T16:21
Table of Contents
想請問Group by的觀念問題,
Employee(e#,phone,dno) 主鍵:e#
Dept(d#,dname) 主鍵:d#
查詢:列出部門名稱及各部門人數
SELECT dname,count(*)
FROM Employee,Dept
WHERE dno=d#
GROUP BY dname;
我的疑慮是假設部門名稱有可能重複,那麼GROUP BY dname是不是查詢結果就有可能不正確?
如果我改寫成:
SELECT dname,count(*)
FROM Employee,Dept
WHERE dno=d#
GROUP BY d#,dname;
這樣可以嗎? 謝謝大家!!
--
Sent from my Android
--
Employee(e#,phone,dno) 主鍵:e#
Dept(d#,dname) 主鍵:d#
查詢:列出部門名稱及各部門人數
SELECT dname,count(*)
FROM Employee,Dept
WHERE dno=d#
GROUP BY dname;
我的疑慮是假設部門名稱有可能重複,那麼GROUP BY dname是不是查詢結果就有可能不正確?
如果我改寫成:
SELECT dname,count(*)
FROM Employee,Dept
WHERE dno=d#
GROUP BY d#,dname;
這樣可以嗎? 謝謝大家!!
--
Sent from my Android
--
Tags:
考試
All Comments
By Blanche
at 2014-04-06T05:39
at 2014-04-06T05:39
By Joseph
at 2014-04-08T16:23
at 2014-04-08T16:23
By Catherine
at 2014-04-11T07:46
at 2014-04-11T07:46
By Wallis
at 2014-04-14T23:59
at 2014-04-14T23:59
By Skylar DavisLinda
at 2014-04-16T08:01
at 2014-04-16T08:01
By Erin
at 2014-04-21T05:01
at 2014-04-21T05:01
By Adele
at 2014-04-22T05:04
at 2014-04-22T05:04
Related Posts
海巡特考考試科目
By Dorothy
at 2014-04-03T14:57
at 2014-04-03T14:57
英文文法一題
By Margaret
at 2014-04-03T14:43
at 2014-04-03T14:43
很膩
By Noah
at 2014-04-03T14:33
at 2014-04-03T14:33
中會應收票據之改正分錄一題
By Frederic
at 2014-04-03T13:45
at 2014-04-03T13:45
今年各項國營事業考試日期
By Dinah
at 2014-04-03T13:31
at 2014-04-03T13:31