作者s900362123 (s900362123)
看板Database
标题[SQL ] 请问 103年软体设计竞赛题目
时间Fri Jul 17 21:54:33 2015
内容/问题描述:
请找出'groupB'参赛队伍的答题中没有任一小题为0分的队伍,列出队伍编号。显示结果
采用队伍编号由小而大排序显示,且同一队伍编号不重复显示。
资料结构 :
item_score
groupname 可变长度字串(长度为10) –参赛组别, 分成’groupA’及’groupB’
teamno 可变长度字串(长度为8) –队伍编号
pnum 整数(长度为2) – 题号, 预设值为0
score 整数(长度为4) – 该题得分, 预设值为0
其中group、teamno 和pnum合起来为主键(primary key)。
这是我写的
select a.groupname,a.teamno,a.pnum,a.score from
(select * from item_score where groupname="groupB" and score<>0)a,
(select * from item_score where groupname="groupB" and score=0 group by
teamno)b
where a.teamno <> b.teamno
group by teamno
我先找出B所有的分数,再找出B 分数=0的资料 然後group by teamno
条件所有的teamno不等於 B分数=0的teamno
但是结果还是有=0的 teamno
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 114.45.179.60
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Database/M.1437141276.A.3AE.html
1F:→ s900362123: 忘记说了 我是用 mysql 07/17 21:55