count statement

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bsder

    count statement

    Hi,

    If I want to select a result that based on the value of count (eg.
    count(*) > 5), how can I write a sql to do that?

    eg.
    select count(*)>5
    from Flight
    where OperationType = "Departure"
    group by Airline, Runway
    order by Date

    Thanks
    D
  • Felix Geerinckx

    #2
    Re: count statement

    On 13/07/2005, bsder wrote:
    [color=blue]
    > If I want to select a result that based on the value of count (eg.
    > count(*) > 5), how can I write a sql to do that?
    >
    > eg.
    > select count(*)>5
    > from Flight
    > where OperationType = "Departure"
    > group by Airline, Runway
    > order by Date[/color]

    select *
    from Flight
    where OperationType = "Departure"
    group by Airline, Runway
    order by Date
    HAVING count(*)>5

    --
    felix

    Comment

    • jm1974

      #3
      Re: count statement

      I don't believe it's possible in one query, but I can't guarantee.

      I do it in two queries :
      select <primarykey>, count(airline) as cnt_airline into temporary table
      FLIGHT_GREATER5
      from Flight
      where OperationType = "Departure"
      group by Airline, Runway
      HAVING cnt_airline > 5;

      select Flight.*
      from Flight, FLIGHT_GREATER5
      where Flight.<primary key> = FLIGHT_GREATER5 .<primarykey>;

      Comment

      Working...