上面的结果集我就是用这个SQL语句取出来的
select wholecoach.start_date as 开班日期,wholecoach.runline as 运行线路,wholecoach.price as 票价,fare.station as 站名,wholecoach.direction as 方向,station.distance as 里程,station.type1 as 省份 from fare,wholecoach,station where fare.code=wholecoach.runline and fare.memorial=station.memorial and wholecoach.terminal='荆门'
select wholecoach.start_date as 开班日期,wholecoach.runline as 运行线路,wholecoach.price as 票价,fare.station as 站名,wholecoach.direction as 方向,station.distance as 里程,station.type1 as 省份 from fare,wholecoach,station where fare.code=wholecoach.runline and fare.memorial=station.memorial and wholecoach.terminal='荆门'
select wholecoach.start_date as 开班日期,wholecoach.runline as 运行线路,wholecoach.price as 票价,fare.station as 站名,wholecoach.direction as 方向,station.distance as 里程,station.type1 as 省份 from fare,wholecoach,station where fare.code=wholecoach.runline and fare.memorial=station.memorial and wholecoach.terminal='荆门'
) tem where 开班日期=(select max(wholecoach.start_date) from fare,wholecoach where wholecoach.terminal='荆门' and fare.code=wholecoach.runline and fare.station=tem.站名)
select wholecoach.start_date as 开班日期,wholecoach.runline as 运行线路,wholecoach.price as 票价,fare.station as 站名,wholecoach.direction as 方向,station.distance as 里程,station.type1 as 省份 from fare,wholecoach,station where fare.code=wholecoach.runline and fare.memorial=station.memorial and wholecoach.terminal='荆门'
) a where 开班日期=(select max(开班日期) from(
select wholecoach.start_date as 开班日期,wholecoach.runline as 运行线路,wholecoach.price as 票价,fare.station as 站名,wholecoach.direction as 方向,station.distance as 里程,station.type1 as 省份 from fare,wholecoach,station where fare.code=wholecoach.runline and fare.memorial=station.memorial and wholecoach.terminal='荆门'
) a where 站名=a.站名)
select fare.station as 站名,wholecoach.price as 票价 from wholecoach,fare,station where wholecoach.terminal='荆门' and wholecoach.runline=fare.code and fare.memorial=station.memorial group by fare.station,wholecoach.price order by wholecoach.price
上面的语句得到:
广华寺 .0000
荆门 .0000
李市 .0000
龙尾山 .0000
七里湖 .0000
钱场 .0000
沙洋 .0000
雁门口 .0000
杨家丰 .0000
易家岭 .0000
皂市 .0000
广华寺 52.0000
荆门 52.0000
李市 52.0000
沙洋 52.0000
广华寺 54.5000
荆门 54.5000
李市 54.5000
沙洋 54.5000
广华寺 57.5000
荆门 57.5000
李市 57.5000
沙洋 57.5000
广华寺 58.0000
荆门 58.0000
沙洋 58.0000
广华寺 65.0000
荆门 65.0000
李市 65.0000
沙洋 65.0000
荆门 66.0000
沙洋 66.0000
荆门 81.0000
沙洋 81.0000
因为我要按票价排序,所以要加入票价
我现在想把每个站名各取出一个,怎么改?