行转列的问题
帮助.rar
(1.35 KB)
CLOSE DATABASES ALL USE 结果 IN 1 ZAP INSERT INTO 结果 (学号, 姓名) SELECT DISTINCT 学号, 姓名 FROM 原始表 INDEX ON ALLTRIM(学号) + ALLTRIM(姓名) TAG aa USE 原始表 IN 2 SELECT 原始表 SET RELATION TO ALLTRIM(学号) + ALLTRIM(姓名) INTO 结果 SCAN REPLACE ("年" + ALLTRIM(原始表.课目)) WITH 原始表.成绩 IN 结果 ENDSCAN SET RELATION TO SELECT 结果 SET ORDER TO BROWSE
CLOSE tables ALL xx=SET('SAFETY') SET SAFETY Off Select distinct 学号, 姓名 From 原始表 INTO dbf 结果 Select Distinct 课目 From 原始表 Into cursor kcmcmp FOR i=1 TO RECCOUNT('kcmcmp') SELECT kcmcmp GO i zdmc='年'+ALLTRIM(课目) ALTER table 结果 ADD &zdmc c(20) ENDFOR SELECT 结果 INDEX ON ALLTRIM(学号) TAG xh SELECT 原始表 SET RELATION TO ALLTRIM(学号) INTO 结果 SCAN REPLACE ("年" + ALLTRIM(原始表.课目)) WITH 原始表.成绩 IN 结果 ENDSCAN SET RELATION TO SELECT 结果 SET ORDER TO SET SAFETY &xx BROWSE