S
sunke520
Unregistered / Unconfirmed
GUEST, unregistred user!
我是个D7新手,现请各位大虾帮忙编写语句实现这个监测功能:“在每年3-4月间每日扫描各站过程降水量,过程降水量是指1天或者连续几天有降水,允许一天无降水,若降水量≥20毫米,则计此站有首场透雨。”var message_by,by, message_by1:string;
s1,s2,form1,form2:string;
time1:string;
time2:tdatetime;
begin
time1:=datetostr(indate) ;
//当前时间 time2:=indate-2;
//当前时间往前推2天 s1:='';
s2:='';
form1:='表1';
form2:='表2';
message_by:='';
s1:='select count(*) as times, stationname as 站点,sum(ra) as 过程降水量from ';
s1:=s1+''+form1+','+form2+' where '+form1+'.stationid='+form2+'.stationid and obsdate between '+#39+datetostr(time2)+#39+' and '+#39+time1+#39+' and ;
s1:=s1+'(month(obsdate) between 3 and 5) group by stationname having (sum(ra)>=20) order by times desc';
adoquery1.Close;
adoquery1.SQL.clear;
adoquery1.SQL.Add(s1);
adoquery1.open;
adoquery1.First;while not adoquery1.Eofdo
begin
by:=ADOQuery1.FieldByName('times').AsString;
if strtoint(by) >= 3then
//发生下雨的天数是3天 begin
message_by1:=message_by1+trim(adoquery1.fieldbyname ( 'stationname').AsString;
end;
adoquery1.Next ;
end;
end;
这样只能实现连续3天有降雨,不能达到”连续几天有降水,允许一天无降水“这个要求,请大侠帮忙改进,跪谢!!!
s1,s2,form1,form2:string;
time1:string;
time2:tdatetime;
begin
time1:=datetostr(indate) ;
//当前时间 time2:=indate-2;
//当前时间往前推2天 s1:='';
s2:='';
form1:='表1';
form2:='表2';
message_by:='';
s1:='select count(*) as times, stationname as 站点,sum(ra) as 过程降水量from ';
s1:=s1+''+form1+','+form2+' where '+form1+'.stationid='+form2+'.stationid and obsdate between '+#39+datetostr(time2)+#39+' and '+#39+time1+#39+' and ;
s1:=s1+'(month(obsdate) between 3 and 5) group by stationname having (sum(ra)>=20) order by times desc';
adoquery1.Close;
adoquery1.SQL.clear;
adoquery1.SQL.Add(s1);
adoquery1.open;
adoquery1.First;while not adoquery1.Eofdo
begin
by:=ADOQuery1.FieldByName('times').AsString;
if strtoint(by) >= 3then
//发生下雨的天数是3天 begin
message_by1:=message_by1+trim(adoquery1.fieldbyname ( 'stationname').AsString;
end;
adoquery1.Next ;
end;
end;
这样只能实现连续3天有降雨,不能达到”连续几天有降水,允许一天无降水“这个要求,请大侠帮忙改进,跪谢!!!