Friday, March 9, 2012

Join.

select e.dname, count(e.sid) as total_num from enroll e
group by e.dname

select e.dname, count(e.sid) as "major_enroll"
from enroll e, major m
where e.sid = m.sid and e.dname = m.dname
group by e.dname
----------------------
Hi, buddys,
How can I join above two results of queries by dname if I don't have any create temporary table permission?

Thx,

Neilselect e.dname, count(e.sid) as total_num
from enroll e
group by e.dname

UNION

select e.dname, count(e.sid) as "major_enroll"
from enroll e, major m
where e.sid = m.sid
and e.dname = m.dname
group by e.dname;

It works with Oracle ...|||Originally posted by Littlefoot

select e.dname, count(e.sid) as total_num
from enroll e
group by e.dname

UNION

select e.dname, count(e.sid) as "major_enroll"
from enroll e, major m
where e.sid = m.sid
and e.dname = m.dname
group by e.dname;

It works with Oracle ...|||I don't need to union set, I mean.
I want total_num and major_enroll are two columns in the same table.

thx.
neil

Originally posted by Littlefoot

select e.dname, count(e.sid) as total_num
from enroll e
group by e.dname

UNION

select e.dname, count(e.sid) as "major_enroll"
from enroll e, major m
where e.sid = m.sid
and e.dname = m.dname
group by e.dname;

It works with Oracle ...

No comments:

Post a Comment