Dividing two Count() Results

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

    Dividing two Count() Results

    Just a quick question, how do I divide the results of these two queries
    together ?

    (select count (*) as ontime from schedule where actualarrivalda te <=
    estimatearrival date)

    (select count (*) as total from schedule)


    Thanks for any help
    Robert


  • David Portas

    #2
    Re: Dividing two Count() Results

    SELECT ontime, total, ontime/CAST(total AS REAL)
    FROM
    (SELECT COUNT(CASE WHEN actualarrivalda te <= estimatearrival date
    THEN 1 END), COUNT(*)
    FROM schedule) AS X(ontime,total)

    (untested)

    --
    David Portas
    ------------
    Please reply only to the newsgroup
    --


    Comment

    • Robert

      #3
      Re: Dividing two Count() Results

      Thanks for the quick reply, the query worked perfect.
      Cheers
      Robert


      "David Portas" <REMOVE_BEFORE_ REPLYING_dporta s@acm.org> wrote in message
      news:nMadnd4h2Z NOrveiRVn-hw@giganews.com ...[color=blue]
      > SELECT ontime, total, ontime/CAST(total AS REAL)
      > FROM
      > (SELECT COUNT(CASE WHEN actualarrivalda te <= estimatearrival date
      > THEN 1 END), COUNT(*)
      > FROM schedule) AS X(ontime,total)
      >
      > (untested)
      >
      > --
      > David Portas
      > ------------
      > Please reply only to the newsgroup
      > --
      >
      >[/color]


      Comment

      Working...