您的位置:程序门 -> delphi -> 数据库相关



确定一个或多个数值


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


确定一个或多个数值[已结贴,结贴人: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  
                                      .
                                      .
                                      .
  
发表于:2007-09-13 11:15:251楼 得分:0
up
发表于:2007-09-13 11:16:452楼 得分:0
查询结果是怎样的?
发表于:2007-09-13 11:21:023楼 得分:0
描述得太不清楚了
select   机组型号   from   表   where   制冷量=102.55   and   出水温度=8.0;
发表于:2007-09-13 11:30:494楼 得分:0
可以是我描述得太不清楚,要通过给定的制冷量,出水温度;先求出最接近给定的制冷量,出水温度,再通过求出的最接近制冷量,出水温度;来确定机组型号 
发表于:2007-09-13 11:32:145楼 得分:0
可能给定的制冷量,出水温度在库里不存在但必须找出最接近的值
发表于:2007-09-13 12:00:376楼 得分:0
存储过程来实现可以么,你用什么数据库?
发表于:2007-09-13 12:11:337楼 得分:0
我用的是access呀
发表于:2007-09-13 13:26:148楼 得分:0
sql code
对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) )
发表于:2007-09-13 13:48:559楼 得分:0
好的本人先试一下
发表于:2007-09-13 14:06:5710楼 得分:0
如果制冷量与102.55最接近的记录,怎么会没有记录呀,     机组型号为空,制冷量:0,出水温度:0  
             
发表于:2007-09-13 14:51:5611楼 得分:0
如果我要对制冷量: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  

请问题如何实现


发表于:2007-09-13 15:16:2912楼 得分:0
我现在只能查询出出水温度: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最接近的记录:  
???????????????????
发表于:2007-09-13 15:59:1813楼 得分:0
delphi(pascal) code
看看这个行不行 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
发表于:2007-09-13 15:59:5814楼 得分:0
sql code
看看这个行不行 select t.aa,min(t.bb) as bb,t.cc fromselect max(bb),aa,cc fromselect 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 fromselect 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
发表于:2007-09-13 16:01:3415楼 得分:0
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
发表于:2007-09-13 16:42:5016楼 得分:0
失踪的月亮--我在access中执行怎么提示:该特定字段t.bb可以参考sql语句中的from子句列表中的多表
发表于:2007-09-13 16:44:2517楼 得分:100
sql code
这样 select t3.aa,min(t3.bb) as bb,t3.cc fromselect max(bb),aa,cc fromselect 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 fromselect 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
发表于:2007-09-13 17:17:5618楼 得分:0
提示:试图执行的查询中不包含作为合计函数一部份的特定表达式'aa'


快速检索

最新资讯
热门点击