作者tracy217 (T大)
看板Database
标题Re: [SQL ] 请问 103年软体设计竞赛题目
时间Sat Jul 18 14:23:24 2015
※ 引述《s900362123 (s900362123)》之铭言:
: 内容/问题描述:
: 请找出'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
--所有队伍 - 有题目0分的队伍 = 答案
select teamno
from item_scrore
where groupname = 'grouopB'
except
select teamno
from item_scrore
where groupname = 'grouopB'
and score = 0
order by teamno
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 61.223.208.66
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Database/M.1437200607.A.4AE.html