由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - Another one
相关主题
SQL question HELPoracle pl sql recursive function
这二句为什么会抛出ClassCastException异常?如何完成这个sql?
Oracle / DB2 问题怎样找odd和even row
Oracle char AND varchar2 datatype question.query 求助
菜鸟急问ORACLE里FUNCTION返回ref cursor的问题吃了包子, 幹活了!
怎么去除duplicatesUrgent SQL problem!
请教: SQL SUMA wield thing in Oracle DB
请问出这个题并给这样answer key的人是什么样的水准?sybase如何实现create table as (select *)
相关话题的讨论汇总
话题: activity话题: actid话题: select话题: another
进入Database版参与讨论
1 (共1页)
h******t
发帖数: 27
1
how many students participate in the most popular student activity
what's the name of this actiity
ACTIVITY (
actid number ,
activity_name varchar2(25)
);
PARTICIPATES_IN (
stuid number,
actid number
);
w*****g
发帖数: 198
2
another one? :)
is this your homework assignment for database class?

【在 h******t 的大作中提到】
: how many students participate in the most popular student activity
: what's the name of this actiity
: ACTIVITY (
: actid number ,
: activity_name varchar2(25)
: );
: PARTICIPATES_IN (
: stuid number,
: actid number
: );

h******t
发帖数: 27
3

come on, help me, due tomorrow

【在 w*****g 的大作中提到】
: another one? :)
: is this your homework assignment for database class?

p*****y
发帖数: 69
4
总觉得这种做法不太好.

【在 h******t 的大作中提到】
:
: come on, help me, due tomorrow

s*i
发帖数: 5025
5
creat view A-N(actid,c)
as select actid, count(*)
from participates_in
group by actid;
select activity_name, Max(c)
from A-N, ACTIVITY
where A-N.actid=activity.actid;

【在 h******t 的大作中提到】
:
: come on, help me, due tomorrow

h******t
发帖数: 27
6

不懂就问,有啥不好
不懂装懂不好,太害羞也不好

【在 p*****y 的大作中提到】
: 总觉得这种做法不太好.
h******t
发帖数: 27
7
I got in this way, never thought use view
thanks sui
SELECT C1, activity_name
FROM (SELECT COUNT(stuid) C1, activity_name
FROM (SELECT Participates_in.stuid, Activity.activity_name
FROM Participates_in , Activity
WHERE Participates_in.actid=Activity.actid)
GROUP BY activity_name)
WHERE C1= (SELECT MAX(C2) FROM (SELECT COUNT(stuid) C2
FROM Participates_in GROUP BY Participates_in.actid));

【在 s*i 的大作中提到】
: creat view A-N(actid,c)
: as select actid, count(*)
: from participates_in
: group by actid;
: select activity_name, Max(c)
: from A-N, ACTIVITY
: where A-N.actid=activity.actid;

q*j
发帖数: 156
8
Is there any requirements to use just one query? "create view" is
considered as one query itself.
If it's homework question, you'd better check the requirement, otherwise,
"create view" is a more intuitive way to do the query.

【在 h******t 的大作中提到】
: I got in this way, never thought use view
: thanks sui
: SELECT C1, activity_name
: FROM (SELECT COUNT(stuid) C1, activity_name
: FROM (SELECT Participates_in.stuid, Activity.activity_name
: FROM Participates_in , Activity
: WHERE Participates_in.actid=Activity.actid)
: GROUP BY activity_name)
: WHERE C1= (SELECT MAX(C2) FROM (SELECT COUNT(stuid) C2
: FROM Participates_in GROUP BY Participates_in.actid));

s*i
发帖数: 5025
9
I remember we can not embed another SELECT clause in FROM clause!
However, I guess you can JOIN some tables in FROM clause.

【在 h******t 的大作中提到】
: I got in this way, never thought use view
: thanks sui
: SELECT C1, activity_name
: FROM (SELECT COUNT(stuid) C1, activity_name
: FROM (SELECT Participates_in.stuid, Activity.activity_name
: FROM Participates_in , Activity
: WHERE Participates_in.actid=Activity.actid)
: GROUP BY activity_name)
: WHERE C1= (SELECT MAX(C2) FROM (SELECT COUNT(stuid) C2
: FROM Participates_in GROUP BY Participates_in.actid));

q*j
发帖数: 156
10
MySQL can't, but other commercial DB can.

【在 s*i 的大作中提到】
: I remember we can not embed another SELECT clause in FROM clause!
: However, I guess you can JOIN some tables in FROM clause.

s*i
发帖数: 5025
11
I don't even believe ORACLE can.

【在 q*j 的大作中提到】
: MySQL can't, but other commercial DB can.
h******t
发帖数: 27
12

I use Oracle, and it works

【在 s*i 的大作中提到】
: I don't even believe ORACLE can.
1 (共1页)
进入Database版参与讨论
相关主题
sybase如何实现create table as (select *)菜鸟急问ORACLE里FUNCTION返回ref cursor的问题
Which design is better?怎么去除duplicates
誰來解釋一下這是什麼原理请教: SQL SUM
新手学数据库一个简单题求助请问出这个题并给这样answer key的人是什么样的水准?
SQL question HELPoracle pl sql recursive function
这二句为什么会抛出ClassCastException异常?如何完成这个sql?
Oracle / DB2 问题怎样找odd和even row
Oracle char AND varchar2 datatype question.query 求助
相关话题的讨论汇总
话题: activity话题: actid话题: select话题: another