By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,417 Members | 1,845 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,417 IT Pros & Developers. It's quick & easy.

count statement

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.