This is a discussion on Dividing two Count() Results within the SQL Server forums, part of the Microsoft SQL Server category; --> Just a quick question, how do I divide the results of these two queries together ? (select count (*) ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Just a quick question, how do I divide the results of these two queries together ? (select count (*) as ontime from schedule where actualarrivaldate <= estimatearrivaldate) (select count (*) as total from schedule) Thanks for any help Robert |
| |||
| SELECT ontime, total, ontime/CAST(total AS REAL) FROM (SELECT COUNT(CASE WHEN actualarrivaldate <= estimatearrivaldate THEN 1 END), COUNT(*) FROM schedule) AS X(ontime,total) (untested) -- David Portas ------------ Please reply only to the newsgroup -- |
| ||||
| Thanks for the quick reply, the query worked perfect. Cheers Robert "David Portas" <REMOVE_BEFORE_REPLYING_dportas@acm.org> wrote in message news:nMadnd4h2ZNOrveiRVn-hw@giganews.com... > SELECT ontime, total, ontime/CAST(total AS REAL) > FROM > (SELECT COUNT(CASE WHEN actualarrivaldate <= estimatearrivaldate > THEN 1 END), COUNT(*) > FROM schedule) AS X(ontime,total) > > (untested) > > -- > David Portas > ------------ > Please reply only to the newsgroup > -- > > |