确定一个或多个数值

sxlcom 2007-09-13 11:14:24
本人想实现这样的功能,通过给出制冷量的定值和出水温度来确定一个或多个机组型号,
如:给定制冷量:102.55 出水温度:8.0 来确定机组型号;

以下是相关数据:
机组型号               制冷量           出水温度
ICW100              76.0 0.0
81.1 2.0
89.1 5.0
94.7 7.0
103.5 10.0
109.7 12.0
119.3 15.0
136.2 20.0
------------------------------------------------------------------
ICW130 101.8 0.0
108.6 2.0
119.4 5.0
126.9 7.0
138.8 10.0
147.0 12.0
159.8 15.0
182.6 20.0
----------------------------------------------------------------------
ICW165 131.2 0.0
140.0 2.0
153.8 5.0
163.6 7.0
178.8 10.0
189.4 12.0
206.0 15.0
.
.
.
  
...全文
107 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
sxlcom 2007-09-13
  • 打赏
  • 举报
回复
我用的是access呀
hongqi162 2007-09-13
  • 打赏
  • 举报
回复
存储过程来实现可以么,你用什么数据库?
sxlcom 2007-09-13
  • 打赏
  • 举报
回复
可能给定的制冷量,出水温度在库里不存在但必须找出最接近的值
sxlcom 2007-09-13
  • 打赏
  • 举报
回复
可以是我描述得太不清楚,要通过给定的制冷量,出水温度;先求出最接近给定的制冷量,出水温度,再通过求出的最接近制冷量,出水温度;来确定机组型号 
hongqi162 2007-09-13
  • 打赏
  • 举报
回复
描述得太不清楚了
select 机组型号 from 表 where 制冷量=102.55 and 出水温度=8.0;
hongqi162 2007-09-13
  • 打赏
  • 举报
回复
查询结果是怎样的?
ILoveFlower 2007-09-13
  • 打赏
  • 举报
回复
up
sxlcom 2007-09-13
  • 打赏
  • 举报
回复
提示:试图执行的查询中不包含作为合计函数一部份的特定表达式'aa'
hongqi162 2007-09-13
  • 打赏
  • 举报
回复
这样
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
sxlcom 2007-09-13
  • 打赏
  • 举报
回复
失踪的月亮--我在access中执行怎么提示:该特定字段t.bb可以参考SQL语句中的from子句列表中的多表
jing12 2007-09-13
  • 打赏
  • 举报
回复
declare @Water float
declare @Cold float
declare @tmpWater float
declare @tmpCold float
set @Water = 给定出水温度
set @Code = 给定制冷量
select @tmpCold = min(abs(制冷量-@Code)) from 表名
select @tmpWater = min(abs(出水温度-@Water)) from (select * from 表名 where 制冷量=@tmpCold)
select * from 表名 where 出水温度 = @tmpWater
hongqi162 2007-09-13
  • 打赏
  • 举报
回复

看看这个行不行
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
hongqi162 2007-09-13
  • 打赏
  • 举报
回复

看看这个行不行
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
sxlcom 2007-09-13
  • 打赏
  • 举报
回复
我现在只能查询出出水温度:6的最接近的记录:

select bb from aaa where cc= (
SELECT max( cc ) from aaa where cc<=6 )
union all

select bb from aaa where cc= (
SELECT min( cc ) from aaa where cc>=6)

请问大家如果再通过这个结果集再进行对制冷量:119.35最接近的记录:
???????????????????
sxlcom 2007-09-13
  • 打赏
  • 举报
回复
如果我要对制冷量:119.35,出水温度:6来确定机组型号;
首先应该先查出,出水温度:6的最接近的记录:
ICW100 89.1 5.0
94.7 7.0
ICW130 119.4 5.0
126.9 7.0

ICW165 153.8 5.0
163.6 7.0


再进行对制冷量:119.35最接近的记录:
ICW130 119.4 5.0

请问题如何实现



sxlcom 2007-09-13
  • 打赏
  • 举报
回复
如果制冷量与102.55最接近的记录,怎么会没有记录呀, 机组型号为空,制冷量:0,出水温度:0
sxlcom 2007-09-13
  • 打赏
  • 举报
回复
好的本人先试一下
hongqi162 2007-09-13
  • 打赏
  • 举报
回复
对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)
)

2,497

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧