Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2004
    Posts
    7

    Question Unanswered: 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?

  2. #2
    Join Date
    Apr 2004
    Posts
    7
    oh yeah, another thing. My outer query select can only have 2 columns (material, height)

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    select material
         , height
      from Materials ZZ
     where height
         > ( select avg(height)
               from Materials
              where MCode = ZZ.MCode )
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •