String tz=patientinfo.getBrtz();
String age=patientinfo.getNl();
String sql="select Fhz from who_age_weight where Sex='"+sex+"' and Weight='"+tz+"' and Age='"+age+"'";
int i=0;
String k5="";
i=igeneralDAO.count(sql);
if(i==0){//没有符合条件的值,那只能利用靠拢原则进行判断,取离其值最近的作为标准
/***********************************取接近tz的最大值***************************/
String sql1="select Weight from who_age_weight where Age='"+age+"' and Sex='"+sex+"' and Weight>="+tz+ " limit 1";
String sql2="select Weight from who_age_weight where Age='"+age+"' and Sex='"+sex+"' and Weight<="+tz+" group by Weight desc limit 1";
/*********************************** 取接近tz的最小值***************************/
List list1=igeneralDAO.findBySQL(sql1);
Iterator it1=list1.iterator();
double tz1=Double.parseDouble(tz);
double k2=0.0;
double k1=0.0;
System.out.println("你输入的的体重是"+tz);
if(it1.hasNext()==false){
k5="没有符合这个体重的测试值,请检查信息是否输入错误";
return k5;
}
while(it1.hasNext()){
k1=Double.parseDouble(it1.next().toString());//最大值
System.out.println("最大值k1:"+k1);
}
List list2=igeneralDAO.findBySQL(sql2);//最小值
Iterator it2=list2.iterator();
if(it2.hasNext()==false){
k5="没有符合这个体重的测试值,请检查信息是否输入错误";
return k5;
}
while(it2.hasNext()){
k2=Double.parseDouble(it2.next().toString());
System.out.println("最小值k2:"+k2);
}
System.out.println("(tz1-k2):"+(tz1-k2));
System.out.println("(k1-tz1):"+(k1-tz1));
if((tz1-k2)>=(k1-tz1)){
String k3=String.valueOf(k1);
String sql3="select Fhz from who_age_weight where Sex='"+sex+"' and Weight='"+k3+"' and Age='"+age+"'";
System.out.println("离最大值"+k3+"差距更小"+sql3);
List list=igeneralDAO.findBySQL(sql3);
Iterator it=list.iterator();
while(it.hasNext()){
k5=it.next().toString();
}
return k5;
}else
{
String k6=String.valueOf(k2);
String sql4="select Fhz from who_age_weight where Sex='"+sex+"' and Weight='"+k6+"' and Age='"+age+"'";
System.out.println("离最小值"+k6+"差距更小"+sql4);
List list=igeneralDAO.findBySQL(sql4);
Iterator it=list.iterator();
while(it.hasNext()){
k5=it.next().toString();
}
return k5;
}
}else if(i>1){ //利用查询后有符合条件的数据直接返回所查到的值
List list=igeneralDAO.findBySQL(sql);
Iterator it=list.iterator();
while(it.hasNext()){
k5=it.next().toString();
}
return k5;
}
return null;
}
分享到:
相关推荐
Oracle分页(limit方式的运用)Oracle分页(limit方式的运用)
SSM框架(Maven项目)-limit 分页实例 SSM框架(Maven项目)-limit 分页实例
select * from table LIMIT 5,10; #返回第6-15行数据 select * from table LIMIT ...传统方式是先取了前90001条记录,取其中最大一个ID值作为起始标识,然后利用它可以快速定位下100条记录 改造方式是仅仅取90000条记录后
nginx_limit_access_module - 可通过指定的 HTTP POST 接口中的值来拒绝请求。 示例配置: http { limit_access_zone zone=one:5m bucket_number=10007 type=ip; server { listen 80; server_name ...
C#限制鼠标活动区域,限制鼠标的活动区域,当然也可以解锁
SQL数据库不支持limit语法,利用逻辑处理函数模拟出来的思路,具体可照此改造。
在mysql中使用limit传参的方法,一个简单的实例
windows系统下内存压力测试工具testlimit.exe
本文档针对mysql分页之limit慢的问题,使用联合索引在大数据量的情况下优化limit分页的性能
WASTEWATER DISCHARGE LIMIT
Java代码替换mysql limit语句可用于分页
主要介绍了使用limit,offset分页场景时为什么会慢,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
p-limit, 运行多个保证并发的&异步函数 限制 运行多个保证并发的&异步函数安装$ npm install p-limit用法const pLimit = require('p-limit');const limit = pLim
关于sqlite使用limit的一些详细说明
order by id desc limit 10 按照id的倒序排序 取出前10条 order by id desc limit 0,10 按照id的倒序排序 取出前10条 order by id limit 5,10 按照id的正序排序 从第5条开始取10条 代码如下: SELECT cat_id FROM ...
a proof of the central limit theorem For Statistics Inference
RamTool - TestLimit 可測試記憶體(填滿、測試系統崩潰邊緣)
Central Limit Theorem
set_time_limit
infinity and limit concept