请教,如何编程把c1995和c1996表变成tt1表?
请各位老师赐教,如何编程把c1995和c1996表变成tt1表,感谢。
close all
clear
set safe off
Create table c1995 (cname c(8),cyear c(4), ms1 n(9,2), ms2 n(9,2),ms3 n(9,2), ms4 n(9,2),;
ms5 n(9,2), ms6 n(9,2),ms7 n(9,2), ms8 n(9,2),ms9 n(9,2), ms10 n(9,2),ms11 n(9,2), ms12 n(9,2))
insert into c1995 (cname,cyear,ms1,ms2,ms3,ms4,ms5,ms6,ms7,ms8,ms9,ms10,ms11,ms12);
value ("mimi","1995",850,860,870,880,890,900,910,920,930,940,1040,1200)
insert into c1995 (cname,cyear,ms1,ms2,ms3,ms4,ms5,ms6,ms7,ms8,ms9,ms10,ms11,ms12);
value ("cici","1995",890,900,910,920,930,940,950,960,980,990,1080,1300)
insert into c1995 (cname,cyear,ms1,ms2,ms3,ms4,ms5,ms6,ms7,ms8,ms9,ms10,ms11,ms12);
value ("gigi","1995",980,990,1040,1050,1060,1070,1080,1090,1100,1150,1130,1150)
brow
Create table c1996 (cname c(8),cyear c(4), ms1 n(9,2), ms2 n(9,2),ms3 n(9,2), ms4 n(9,2),;
ms5 n(9,2), ms6 n(9,2),ms7 n(9,2), ms8 n(9,2),ms9 n(9,2), ms10 n(9,2),ms11 n(9,2), ms12 n(9,2))
insert into c1996 (cname,cyear,ms1,ms2,ms3,ms4,ms5,ms6,ms7,ms8,ms9,ms10,ms11,ms12);
value ("hans","1996",920,930,940,950,960,970,980,990,1020,1030,1080,1250)
insert into c1996 (cname,cyear,ms1,ms2,ms3,ms4,ms5,ms6,ms7,ms8,ms9,ms10,ms11,ms12);
value ("james","1996",990,1020,1030,1040,1050,1060,1070,1080,1090,1100,1150,1160)
insert into 1996 (cname,cyear,ms1,ms2,ms3,ms4,ms5,ms6,ms7,ms8,ms9,ms10,ms11,ms12);
value ("rocks","1996",985,995,1080,1090,1120,1160,1180,1130,1210,1250,1280,1290)
brow
Create table tt1 (cname c(8),cyear c(4),cmonth c(4), salary n(9,2))
brow
*tt1
* cname cyear cmonth salary
* mimi 1995 1 850
* mimi 1995 2 860
* mimi 1995 3 870
* ...........
* gigi 1995 11 1130
* gigi 1995 12 1150
* hans 1996 1 920
* hans 1996 2 930
* ...........
* rocks 1996 11 1280
* rocks 1996 12 1290
[解决办法]
Create Cursor c1995 (cname c(8),cyear c(4), ms1 N(9,2), ms2 N(9,2),ms3 N(9,2), ms4 N(9,2),; ms5 N(9,2), ms6 N(9,2),ms7 N(9,2), ms8 N(9,2),ms9 N(9,2), ms10 N(9,2),ms11 N(9,2), ms12 N(9,2))Insert Into c1995 (cname,cyear,ms1,ms2,ms3,ms4,ms5,ms6,ms7,ms8,ms9,ms10,ms11,ms12); value ("mimi","1995",850,860,870,880,890,900,910,920,930,940,1040,1200)Insert Into c1995 (cname,cyear,ms1,ms2,ms3,ms4,ms5,ms6,ms7,ms8,ms9,ms10,ms11,ms12); value ("cici","1995",890,900,910,920,930,940,950,960,980,990,1080,1300)Insert Into c1995 (cname,cyear,ms1,ms2,ms3,ms4,ms5,ms6,ms7,ms8,ms9,ms10,ms11,ms12); value ("gigi","1995",980,990,1040,1050,1060,1070,1080,1090,1100,1150,1130,1150)BrowCreate Cursor c1996 (cname c(8),cyear c(4), ms1 N(9,2), ms2 N(9,2),ms3 N(9,2), ms4 N(9,2),; ms5 N(9,2), ms6 N(9,2),ms7 N(9,2), ms8 N(9,2),ms9 N(9,2), ms10 N(9,2),ms11 N(9,2), ms12 N(9,2))Insert Into c1996 (cname,cyear,ms1,ms2,ms3,ms4,ms5,ms6,ms7,ms8,ms9,ms10,ms11,ms12); value ("hans","1996",920,930,940,950,960,970,980,990,1020,1030,1080,1250)Insert Into c1996 (cname,cyear,ms1,ms2,ms3,ms4,ms5,ms6,ms7,ms8,ms9,ms10,ms11,ms12); value ("james","1996",990,1020,1030,1040,1050,1060,1070,1080,1090,1100,1150,1160)Insert Into c1996 (cname,cyear,ms1,ms2,ms3,ms4,ms5,ms6,ms7,ms8,ms9,ms10,ms11,ms12); value ("rocks","1996",985,995,1080,1090,1120,1160,1180,1130,1210,1250,1280,1290)BrowseCreate Table tt1 (cname c(8),cyear c(4),Cmonth c(4), salary N(9,2))Select c1995Scan For lnI=1 To 12 Insert Into tt1 Values (c1995.cname,c1995.cyear,'ms'+Transform(lnI),Evaluate('c1995.ms'+Transform(lnI))) EndforEndscanSelect c1996Scan For lnI=1 To 12 Insert Into tt1 Values (c1996.cname,c1996.cyear,'ms'+Transform(lnI),Evaluate('c1996.ms'+Transform(lnI))) EndforEndscanSelect tt1Browse
[解决办法]
close all
clear
set safe off
Create table c1995 (cname c(8),cyear c(4), ms1 n(9,2), ms2 n(9,2),ms3 n(9,2), ms4 n(9,2),;
ms5 n(9,2), ms6 n(9,2),ms7 n(9,2), ms8 n(9,2),ms9 n(9,2), ms10 n(9,2),ms11 n(9,2), ms12 n(9,2))
insert into c1995 (cname,cyear,ms1,ms2,ms3,ms4,ms5,ms6,ms7,ms8,ms9,ms10,ms11,ms12);
value ("mimi","1995",850,860,870,880,890,900,910,920,930,940,1040,1200)
insert into c1995 (cname,cyear,ms1,ms2,ms3,ms4,ms5,ms6,ms7,ms8,ms9,ms10,ms11,ms12);
value ("cici","1995",890,900,910,920,930,940,950,960,980,990,1080,1300)
insert into c1995 (cname,cyear,ms1,ms2,ms3,ms4,ms5,ms6,ms7,ms8,ms9,ms10,ms11,ms12);
value ("gigi","1995",980,990,1040,1050,1060,1070,1080,1090,1100,1150,1130,1150)
brow
Create table c1996 (cname c(8),cyear c(4), ms1 n(9,2), ms2 n(9,2),ms3 n(9,2), ms4 n(9,2),;
ms5 n(9,2), ms6 n(9,2),ms7 n(9,2), ms8 n(9,2),ms9 n(9,2), ms10 n(9,2),ms11 n(9,2), ms12 n(9,2))
insert into c1996 (cname,cyear,ms1,ms2,ms3,ms4,ms5,ms6,ms7,ms8,ms9,ms10,ms11,ms12);
value ("hans","1996",920,930,940,950,960,970,980,990,1020,1030,1080,1250)
insert into c1996 (cname,cyear,ms1,ms2,ms3,ms4,ms5,ms6,ms7,ms8,ms9,ms10,ms11,ms12);
value ("james","1996",990,1020,1030,1040,1050,1060,1070,1080,1090,1100,1150,1160)
insert into c1996 (cname,cyear,ms1,ms2,ms3,ms4,ms5,ms6,ms7,ms8,ms9,ms10,ms11,ms12);
value ("rocks","1996",985,995,1080,1090,1120,1160,1180,1130,1210,1250,1280,1290)
brow
Create table tt1 (cname c(8),cyear c(4),cmonth c(4), salary n(9,2))
FOR i=1995 TO 1996
ff=''
FOR j=1 TO 12
TEXT TO ff NOSHOW TEXTMERGE ADDITIVE
SELECT cname,<<i>>,<<TRANSFORM(j)>>,EVALUATE('ms'+'<<TRANSFORM(j)>>') FROM c<<TRANSFORM(i)>> union
ENDTEXT
NEXT
ff='insert into tt1 '+LEFT(ff,LEN(ff)-6)
?ff
&ff
NEXT
[解决办法]