ÏÈÓÐÁ½ÕÅ±í£¬½á¹¹ÈçÏ£º table1 id ip time table2 id ipnum time ÎÒÏë°Ñtable1ÖÐÏàͬipÔÚͬһÌìÄÚµÄÊýÁ¿²åÈëµ½table2
ÈçÏ£º table1 id ip time 0 11.11 2005-02-13 1 22.33 2005-02-13 2 11.11 2005-02-13 3 22.33 2005-02-13
table2 id ip ipnum time 0 11.11 2 2005-02-13 1 22.33 2 2005-02-13
ÇëÎÊSQLÓï¾äÈçºÎʵÏÖ select ip,time,count(*) from tb1 group by ip,time insert into tb2 select min(id),ip,count(*),time from tb1 group by ip,time SQL code: update t2 set t2.ipnum=t2.ipnum+isnull(t1.cnt,0) from table2 t2 left join (select ip,convert(varchar(10),[time],120) as [time],count(1) as cnt from table1 group by ip,convert(varchar(10),[time],120)) t1 on t1.ip=t2.ip and t1.[time]=convert(varchar(10),t2.[time],120)
ÏÖÔÚÓÐÒ»ORACLEÖеÄSQLÓï¾ä£¬ÐèÒªÒÆÖ²µ½DB2ÖУ¬ÇëÎʸÃSQL¸ÄÈçºÎд ORACLEÖУº select floor(months_between(date1,date2)) from A date1,date2·Ö±ðΪ±íÖеÄÁ½¸ö×Ö¶Î £¬¶¼ÎªÈÕÆÚÐÍ DB2ÖÐÈçºÎʹÓÃÐ ......