471,092 Members | 1,550 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,092 software developers and data experts.

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
Jul 23 '05 #1
2 1517
On 13/07/2005, bsder wrote:
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


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

--
felix
Jul 23 '05 #2
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.<primarykey> = FLIGHT_GREATER5.<primarykey>;

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Good Man | last post: by
2 posts views Thread by Anne Heddal | last post: by
22 posts views Thread by MP | last post: by
4 posts views Thread by Michel Esber | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.