首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > VFP >

请问,怎么编程把temp表变成tmep1表

2012-05-05 
请教,如何编程把temp表变成tmep1表?如何编程把以下temp表变成tmep1表,请各位老师指导、赐教,感谢。CLOSE ALL

请教,如何编程把temp表变成tmep1表?
如何编程把以下temp表变成tmep1表,请各位老师指导、赐教,感谢。
   
  CLOSE ALL 
  CLEAR
  SET SAFETY off
  SET CENTURY on
  SET DATE TO ansi
   
  CREATE table temp(cname c (8),code1 c(8), code2 c(4),amount n (9,2),date1 d(12),date2 d(12))
  INSERT INTO temp VALUES ( "amy","0101","A",143.59,{^2000-09-01},{^2000-09-30})
  INSERT INTO temp VALUES ( "amy","0101","B",47.86,{^2000-09-01},{^2000-09-30})
  INSERT INTO temp VALUES ( "amy","0101","A",420.00,{^2000-10-01},{^2000-10-31})
  INSERT INTO temp VALUES ( "amy","0101","B",140.00,{^2000-10-01},{^2000-10-31})
  INSERT INTO temp VALUES ( "amy","0101","A",380.00,{^2000-11-01},{^2000-11-30})
  INSERT INTO temp VALUES ( "amy","0101","B",138.00,{^2000-11-01},{^2000-11-30})
  INSERT INTO temp VALUES ( "amy","0101","A",290.00,{^2000-12-01},{^2000-12-31})
  INSERT INTO temp VALUES ( "amy","0101","B",136.00,{^2000-12-01},{^2000-12-31})
  INSERT INTO temp VALUES ( "amy","0101","A",390.00,{^2001-01-01},{^2001-01-31})
  INSERT INTO temp VALUES ( "amy","0101","B",138.00,{^2001-01-01},{^2001-01-31})
   
  INSERT INTO temp VALUES ( "amy","0305","A",158.92,{^2000-08-01},{^2000-08-31})
  INSERT INTO temp VALUES ( "amy","0305","B",69.71,{^2000-08-01},{^2000-08-31})
  INSERT INTO temp VALUES ( "amy","0305","A",168.85,{^2000-09-01},{^2000-09-30})
  INSERT INTO temp VALUES ( "amy","0305","B",58.92,{^2000-09-01},{^2000-09-30})
  INSERT INTO temp VALUES ( "amy","0305","A",380.52,{^2000-10-01},{^2000-10-31})
  INSERT INTO temp VALUES ( "amy","0305","B",128.52,{^2000-10-01},{^2000-10-31})
  INSERT INTO temp VALUES ( "amy","0305","A",321.01,{^2000-11-01},{^2000-11-30})
  INSERT INTO temp VALUES ( "amy","0305","B",125.52,{^2000-11-01},{^2000-11-30})
  INSERT INTO temp VALUES ( "amy","0305","A",252.85,{^2000-12-01},{^2000-12-31})
  INSERT INTO temp VALUES ( "amy","0305","B",105.92,{^2000-12-01},{^2000-12-31})
   
  INSERT INTO temp VALUES ( "cici","0201","A",585.00,{^2000-10-01},{^2000-10-31})
  INSERT INTO temp VALUES ( "cici","0201","B",158.00,{^2000-10-01},{^2000-10-31})
  INSERT INTO temp VALUES ( "cici","0201","A",250.00,{^2000-11-01},{^2000-11-30})
  INSERT INTO temp VALUES ( "cici","0201","B",163.50,{^2000-11-01},{^2000-11-30})
  INSERT INTO temp VALUES ( "cici","0201","A",212.00,{^2000-12-01},{^2000-12-31})
  INSERT INTO temp VALUES ( "cici","0201","B",105.00,{^2000-12-01},{^2000-12-31})
  INSERT INTO temp VALUES ( "cici","0201","A",385.00,{^2001-01-01},{^2001-01-31})
  INSERT INTO temp VALUES ( "cici","0201","B",125.00,{^2001-01-01},{^2001-01-31})
  INSERT INTO temp VALUES ( "cici","0201","A",141.59,{^2001-02-01},{^2001-02-28})
  INSERT INTO temp VALUES ( "cici","0201","B",49.86,{^2001-02-01},{^2001-02-28})
   


  INSERT INTO temp VALUES ( "cici","0505","A",425.21,{^2001-01-01},{^2001-01-31})
  INSERT INTO temp VALUES ( "cici","0505","B",152.58,{^2001-01-01},{^2001-01-31})
  INSERT INTO temp VALUES ( "cici","0505","A",152.01,{^2001-02-01},{^2001-02-28})
  INSERT INTO temp VALUES ( "cici","0505","B",101.52,{^2001-02-01},{^2001-02-28})
  INSERT INTO temp VALUES ( "cici","0505","A",585.01,{^2001-03-01},{^2001-03-31})
  INSERT INTO temp VALUES ( "cici","0505","B",196.22,{^2001-03-01},{^2001-03-31})
  INSERT INTO temp VALUES ( "cici","0505","A",221.05,{^2001-04-01},{^2001-04-30})
  INSERT INTO temp VALUES ( "cici","0505","B",114.52,{^2001-04-01},{^2001-04-30})
  INSERT INTO temp VALUES ( "cici","0505","A",274.25,{^2001-05-01},{^2001-05-31})
  INSERT INTO temp VALUES ( "cici","0505","B",115.25,{^2001-05-01},{^2001-05-31})
  brow
   
  ********************************************************************************
  CREATE table temp1(cname c (8),code1 c(8), code2 c(4),amount n (9,2),date1 d(12),date2 d(12))
  INSERT INTO temp1 VALUES ( "amy","0101","A",1623.59,{^2000-09-01},{^2001-01-31})
  INSERT INTO temp1 VALUES ( "amy","0101","B",599.86,{^2000-09-01},{^2001-01-31})
  INSERT INTO temp1 VALUES ( "amy","0305","A",1285.15,{^2000-08-01},{^2000-12-31})
  INSERT INTO temp1 VALUES ( "amy","0305","B",488.59,{^2000-08-01},{^2000-12-31})
  INSERT INTO temp1 VALUES ( "cici","0201","A",1573.59,{^2000-10-01},{^2001-2-28})
  INSERT INTO temp1 VALUES ( "cici","0201","B",601.36,{^2000-10-01},{^2001-2-28})
  INSERT INTO temp1 VALUES ( "cici","0505","A",1657.53,{^2001-01-01},{^2001-05-31})
  INSERT INTO temp1 VALUES ( "cici","0505","B",680.09,{^2001-01-01},{^2001-05-31})
  BROW
 

[解决办法]
Select cname, code1, code2, Sum(amount) as amount, Min(date1) as date1, Max(date2) as date2 ;
from temp into table temp1 ;
group by cname, code1, code2

热点排行