Results 1 to 2 of 2

Thread: [RESOLVED] Conditional Query

Hybrid View

  1. #1

    Thread Starter
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    Resolved [RESOLVED] Conditional Query

    So in the attached database there is a table AIRPORT that contains airportnames, the state where they are located and the opening year.

    The exercise goes as follows:
    Return the number of airports opened after 1935. Only count the airports of which at least 5 exist in the state (all opened after 1935).
    I know the answer is 0 because the table is not that big, but how could I construct a query that retrieves that?

    Query w11g in the database contains what I could figure out.
    (note: I'm using 1900 there as 1935 doesn't have any results)

    Thanks
    Attached Files Attached Files
    Delete it. They just clutter threads anyway.

  2. #2

    Thread Starter
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    Re: Conditional Query

    And nevermind.
    Solved it
    Code:
    SELECT sum(RET) 
    FROM
    
    (SELECT count(*) AS RET
     FROM AIRPORT
     WHERE int(AIRPORT.YEAROPENED)>=1900
     GROUP BY AIRPORT.STATE) 
    
    WHERE RET >=5;
    I'm starting to like this SQL stuff
    Delete it. They just clutter threads anyway.

Posting Permissions

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



Click Here to Expand Forum to Full Width