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 > Another simple SQL query (MS Access)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-29-04, 05:29
Solus Solus is offline
Registered User
 
Join Date: Apr 2004
Posts: 7
Question Another simple SQL query (MS Access)

Hi. I'm having trouble doing another SQL query. It needs to compare a height against the average height of a group. If it is larger, than it is shown. I can create the sub query but it returns an error when going to the outer query.

Code:
Select avg(height) 
from Materials 
group by MCode
What is an outer query that would compare a single height against that groups average height and display the rows if the single height is greater?
Reply With Quote
  #2 (permalink)  
Old 04-29-04, 05:39
Solus Solus is offline
Registered User
 
Join Date: Apr 2004
Posts: 7
oh yeah, another thing. My outer query select can only have 2 columns (material, height)
Reply With Quote
  #3 (permalink)  
Old 04-29-04, 08:00
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Code:
select material
     , height
  from Materials ZZ
 where height
     > ( select avg(height)
           from Materials
          where MCode = ZZ.MCode )
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
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