select min(cost),airline from flight group by airline
select a.source, a.destination, a.cost, a.airline from flight as a, (select source, destination, min(cost) as cost from flight group by source, destination) as b where a.cost = b.cost and a.source = b.source and a.destination = b.destination
select DISTINCT(a.source, a.destination), a.cost, a.airline from flight as a order by cost asc
不是简单的sql语句,里面含有算法的
select min(cost) from flight group by source,destination
(select source, destination, min(cost) as cost from flight
group by source, destination) as b
where a.cost = b.cost
and a.source = b.source
and a.destination = b.destination
但如果没有环,是可以解的,但SQL语句较复杂(要用表的连接,as等)!
谢谢大家的回答。来者有分!