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 > need to get sth which is more than avg

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-23-04, 12:01
hooky hooky is offline
Registered User
 
Join Date: Sep 2004
Posts: 1
need to get sth which is more than avg

Hello,
this gives me average films by distributors:

select avg(tblcnt.cnt) from

(select d.name, count(f.original_tytle) cnt from licences l, distributors d, films f
where l.id_distributor = d.id and f.id_licences = l.id
group by d.name
order by cnt) tblcnt


question:

I want to get distributors they have more films than this average number

Thank you, h
Reply With Quote
  #2 (permalink)  
Old 09-23-04, 14:09
urquel urquel is offline
Registered User
 
Join Date: Aug 2004
Posts: 330
select dd.name, count(ff.original_tytle) cnt from licences ll, distributors dd, films ff
where ll.id_distributor = dd.id and ff.id_licences = ll.id
group by dd.name
having count(ff.original_tytle) >

(select avg(tblcnt.cnt) from

(select d.name, count(f.original_tytle) cnt from licences l, distributors d, films f
where l.id_distributor = d.id and f.id_licences = l.id
group by d.name
order by cnt) tblcnt)
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