Ïëдһ¸ösqlÓï¾ä²éѯ½á¹ûÈçÏ£º ·ÖÊý °à¼¶ ÐÕÃû ËùÔڰ༶×Ü·Ö 60 1°à ÕÅÈý 160 60 1°à ÍõÎå 40 1°à ÀîËÄ 20 2°à ÎâÌÎ 113 50 2°à ÁõÒ» 43 2°à ½«¶þ 79 3°à Сú 189 80 3°à ÁõÌÎ 30 3°à ÀîÁ¦ select *, [ËùÔڰ༶×Ü·Ö]=(select sum(·ÖÊý) from table1 where °à¼¶=T.°à¼¶) from table1 as T ÕâÖÖ½á¹û±í±¾Éí¾ÍÊÇûÓÐÒâÒåµÄ select *,case when ÐÕÃû in(select max(ÐÕÃû) from table1 group by °à¼¶) then (select sum(·ÖÊý) from table1 where °à¼¶=T.°à¼¶) else null end as ËùÔڰ༶×Ü·Ö from table T
ÏÖÔÚÓÐÒ»ORACLEÖеÄSQLÓï¾ä£¬ÐèÒªÒÆÖ²µ½DB2ÖУ¬ÇëÎʸÃSQL¸ÄÈçºÎд ORACLEÖУº select floor(months_between(date1,date2)) from A date1,date2·Ö±ðΪ±íÖеÄÁ½¸ö×Ö¶Î £¬¶¼ÎªÈÕÆÚÐÍ DB2ÖÐÈçºÎʹÓÃÐ ......