表avrefreshtop里,有id(数字),searchkey(varchar(255)),detail(varchar(255)),price(数字),createtime(时间),要求找到searchkey相同时,EK的排名,这里排名按照相同searchkey、createtime的EK的id减去排名第一的id,即是EK的排名,以及排名第一的航司代码及价格,以及EK的价格(price),以及跟第一的差价;最终得到searchkey createtime airline 排名 price 第一的航司 第一的价格 差价
LON|WUH|2016-05-07| 2016-03-15 EK 3 500 MU 350 150
BCN|BJS|2016-04-20| 2016-03-20 EK 5 2200 CA 1900 300目前表结构如下
id searchkey detail price createtime
402180411 MIL|BJS|2016-04-23|2016-08-20 MXP-VIE@2016-04-23 20:00:00@OS516|VIE-PEK 900 2016-04-13
402180412 MIL|BJS|2016-04-23|2016-08-20 EK206/EK308_EK307/EK91|U/U_U/U 1258 2016-04-13
表中OS516与EK206是航班号,OS和EK就是航司,需要找出EK航司的排名,求大神帮忙!!!!!
LON|WUH|2016-05-07| 2016-03-15 EK 3 500 MU 350 150
BCN|BJS|2016-04-20| 2016-03-20 EK 5 2200 CA 1900 300目前表结构如下
id searchkey detail price createtime
402180411 MIL|BJS|2016-04-23|2016-08-20 MXP-VIE@2016-04-23 20:00:00@OS516|VIE-PEK 900 2016-04-13
402180412 MIL|BJS|2016-04-23|2016-08-20 EK206/EK308_EK307/EK91|U/U_U/U 1258 2016-04-13
表中OS516与EK206是航班号,OS和EK就是航司,需要找出EK航司的排名,求大神帮忙!!!!!
searchkey createtime airline 排名 price 第一的航司 第一的价格 差价
LON|WUH|2016-05-07| 2016-04-13 EK 2 1258 OS 900 358
BCN|BJS|2016-04-20| 2016-04-13 EK 2 1500 CA 1000 500目前表结构如下
id searchkey detail price createtime
402180411 LON|WUH|2016-05-07| MXP-VIE@2016-04-13 @OS516 900 2016-04-13
402180412 LON|WUH|2016-05-07| EK206/EK308_EK307/EK91|U/U_U/U 1258 2016-04-13
401578554 BCN|BJS|2016-04-20| CZ6957/CZ343|K/Q 1000 2016-04-13
401578555 BCN|BJS|2016-04-20| EK122/EK308/CA4120|U/U 1500 2016-04-13
from t a cross join (select top 1 price from t order by price) b
order by price