If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Join.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-27-04, 01:55
neiljchen neiljchen is offline
Registered User
 
Join Date: Feb 2004
Posts: 13
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,

Neil
Reply With Quote
  #2 (permalink)  
Old 02-27-04, 02:20
Littlefoot Littlefoot is offline
Lost Boy
 
Join Date: Jan 2004
Location: Croatia, Europe
Posts: 3,629
PHP Code:
select e.dnamecount(e.sid) as total_num 
from enroll e 
group by e
.dname

UNION

select e
.dnamecount(e.sid) as "major_enroll" 
from enroll emajor m 
where e
.sid m.sid 
  
and e.dname m.dname
group by e
.dname
It works with Oracle ...
Reply With Quote
  #3 (permalink)  
Old 02-27-04, 04:56
neiljchen neiljchen is offline
Registered User
 
Join Date: Feb 2004
Posts: 13
Not union

Quote:
Originally posted by Littlefoot
PHP Code:
select e.dnamecount(e.sid) as total_num 
from enroll e 
group by e
.dname

UNION

select e
.dnamecount(e.sid) as "major_enroll" 
from enroll emajor m 
where e
.sid m.sid 
  
and e.dname m.dname
group by e
.dname
It works with Oracle ...
Reply With Quote
  #4 (permalink)  
Old 02-27-04, 04:58
neiljchen neiljchen is offline
Registered User
 
Join Date: Feb 2004
Posts: 13
not union

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

Quote:
Originally posted by Littlefoot
PHP Code:
select e.dnamecount(e.sid) as total_num 
from enroll e 
group by e
.dname

UNION

select e
.dnamecount(e.sid) as "major_enroll" 
from enroll emajor m 
where e
.sid m.sid 
  
and e.dname m.dname
group by e
.dname
It works with Oracle ...
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On