create table table1( u_name varchar2(12), u_telephone varchar(20) ); insert into table1 values('aaa','111111'); insert into table1 values('bbb','22222'); insert into table1 values('ccc','33333'); insert into table1 values('ddd','44444');create table table2( u_id int, time1 varchar2(12), time2 varchar2(12), time3 varchar2(12), time4 varchar2(12), time5 varchar2(12), time6 varchar2(12), time7 varchar2(12), primary key(u_id) ); insert into table2 values(1,'aaa','bbb','ccc','aaa','ccc','ccc','ccc'); insert into table2 values(2,'bbb','bbb','bbb','aaa','bbb','ccc','ccc');create table table3( u_id int, u_money int );insert into table3 select table2.u_id, decode((select time1 from table2 where u_id=1 and time1='aaa'),null,0,4)+ decode((select time2 from table2 where u_id=1 and time2='aaa'),null,0,4)+ decode((select time3 from table2 where u_id=1 and time3='aaa'),null,0,4)+ decode((select time4 from table2 where u_id=1 and time4='aaa'),null,0,4)+ decode((select time5 from table2 where u_id=1 and time5='aaa'),null,0,6)+ decode((select time6 from table2 where u_id=1 and time6='aaa'),null,0,4)+ decode((select time6 from table2 where u_id=1 and time7='aaa'),null,0,4) as time1_num from table1,table2 where table1.u_name=table2.time1 and u_id=1;
u_name varchar2(12),
u_telephone varchar(20)
);
insert into table1 values('aaa','111111');
insert into table1 values('bbb','22222');
insert into table1 values('ccc','33333');
insert into table1 values('ddd','44444');create table table2(
u_id int,
time1 varchar2(12),
time2 varchar2(12),
time3 varchar2(12),
time4 varchar2(12),
time5 varchar2(12),
time6 varchar2(12),
time7 varchar2(12),
primary key(u_id)
);
insert into table2 values(1,'aaa','bbb','ccc','aaa','ccc','ccc','ccc');
insert into table2 values(2,'bbb','bbb','bbb','aaa','bbb','ccc','ccc');create table table3(
u_id int,
u_money int
);insert into table3 select table2.u_id,
decode((select time1 from table2 where u_id=1 and time1='aaa'),null,0,4)+
decode((select time2 from table2 where u_id=1 and time2='aaa'),null,0,4)+
decode((select time3 from table2 where u_id=1 and time3='aaa'),null,0,4)+
decode((select time4 from table2 where u_id=1 and time4='aaa'),null,0,4)+
decode((select time5 from table2 where u_id=1 and time5='aaa'),null,0,6)+
decode((select time6 from table2 where u_id=1 and time6='aaa'),null,0,4)+
decode((select time6 from table2 where u_id=1 and time7='aaa'),null,0,4) as time1_num
from table1,table2 where table1.u_name=table2.time1 and u_id=1;