±ía£º
1 aaa 1 3 //±íʾaaaÊDZíb1-3µÄºÍ
2 bbb 2 4
3 ccc 2 6
±íb£º
1 200
2 300
3 400
4 100
5 150
6 120
ÔõôÄÜдsqlµÃµ½£º
aaa 900
bbb 800
ccc 1070
ÏÈлл¸÷λ£¡
nobody knows£¿£¿£¿
select a,sum(money) from a,b where id >=s and id <= e group by a
with a as(
select 'aaa' a,1 s,3 e from dual
union all
select 'bbb' a,2 s,4 e from dual
union all
select 'ccc' a,2 s,6 e from dual
)
,
b as(
select 1 id,200 money from dual
union all
select 2 id,300 money from dual
union all
select 3 id,400 money from dual
union all
select 4 id,100 money from dual
union all
select 5 id,150 money from dual
union all
select 6 id,120 money from dual
)
select a,sum(money) from a,b where id >=s and id <= e group by a
SQL> select * from a;
COL1 COL2 COL3 COL4
ÎÒÓжà¸ö±íA B C ½á¹¹ÊÇÒ»ÑùµÄ£¬¶¼ÓÐ2¸ö×Ö¶ÎnameºÍcontent,ÎÒÒªËÑË÷ËùÒÔ±íËùÓÐ×Ö¶ÎÖаüº¬¡°Öйú¡±µÄÄÚÈÝ Õâ¸öSQLÓï¾äÔõôд
ÈçºÎ½«¶à¸ö±íµÄ²éѯ½á¹ûÁ¬³ÉÒ»¸ö±í Õâ¸öSQLÓï¾äÔõôд ±íµÄ½á¹¹ÊÇÒ»ÑùµÄ
ÀýÈç£ ......