2,497
社区成员
发帖
与我相关
我的任务
分享
这样
select t3.aa,min(t3.bb) as bb,t3.cc from
(
select max(bb),aa,cc from
(
select aa,bb,cc from aaa where cc= (SELECT max( cc ) from aaa where cc <=6 )
union all
select aa,bb,cc from aaa where cc= (SELECT min( cc ) from aaa where cc >=6)
)t where bb<=119.35
union all
select min(bb),aa,cc from
(
select aa,bb,cc from aaa where cc= (SELECT max( cc ) from aaa where cc <=6 )
union all
select aa,bb,cc from aaa where cc= (SELECT min( cc ) from aaa where cc >=6)
)t1 where bb>=119.35
) t3
看看这个行不行
select t.aa,min(t.bb) as bb,t.cc from
(
select max(bb),aa,cc from
(
select aa,bb,cc from aaa where cc= (SELECT max( cc ) from aaa where cc <=6 )
union all
select aa,bb,cc from aaa where cc= (SELECT min( cc ) from aaa where cc >=6)
)t where bb<=119.35
union all
select min(bb),aa,cc from
(
select aa,bb,cc from aaa where cc= (SELECT max( cc ) from aaa where cc <=6 )
union all
select aa,bb,cc from aaa where cc= (SELECT min( cc ) from aaa where cc >=6)
)t1 where bb>=119.35
) t
看看这个行不行
select t.aa,min(t.bb) as bb,t.cc from
(
select max(bb),aa,cc from
(
select aa,bb,cc from aaa where cc= (SELECT max( cc ) from aaa where cc <=6 )
union all
select aa,bb,cc from aaa where cc= (SELECT min( cc ) from aaa where cc >=6)
)t where bb<=119.35
union all
select min(bb),aa,cc from
(
select aa,bb,cc from aaa where cc= (SELECT max( cc ) from aaa where cc <=6 )
union all
select aa,bb,cc from aaa where cc= (SELECT min( cc ) from aaa where cc >=6)
)t1 where bb>=119.35
) t
对access不熟总感觉写的很麻烦,这个是取出制冷量与3最接近的记录,对结果再对出水温度过滤一遍就是取出制冷量与出水温度最接近的记录
select 机组型号,制冷量,出水温度 from 表1 where aa=iif
(
(SELECT max( 制冷量 ) from 表1 where 制冷量<=3)-(SELECT min( 制冷量 ) from 表1 where 制冷量>=3)>0,
(SELECT min( 制冷量 ) from 表1 where 制冷量>=3),
(SELECT max( 制冷量 ) from 表1 where 制冷量<=3)
)