Insert into A表(A表.a,A表.b,A表.c,A表.d)
Select B表.a,C表.b,count(*),to_date('20081101 110000','yyyymmdd hh24miss')
From A表,B表,C表
Where B表.m=C表.m 
Group by B.a,C表.b,A表.d我要把 A表.d 赋一个固定的值,是这样做吗?

解决方案 »

  1.   


    --改了一下:Insert into A表(a,b,c,d) 
           Select B表.a,
                  C表.b,
                  (select count(*) from b),
                  to_date('20081101 110000','yyyymmdd hh24miss') 
         From B表,C表 
        Where B表.m=C表.m; 
      

  2.   

    最好你把三个表的结构帖出来,只提供sql语句很难看出表之间的关联
      

  3.   


    按B表的字段1数据分组,把A表的字段3填一个固定值。A表的字段1,字段2分别填B表.字段1,和符合分组条件的数据条数
    Insert into A表(字段1,字段2,字段3)
    Select B表.字段1,Count(*), to_date('20081101 110000','yyyymmdd hh24miss')
    From B表
    Group by B表.字段1
    这样大家懂我的意思吧
      

  4.   

    --如对取得的数据进行分组,可以:select tb.a,tc.b,count(*) 
           from tableB tb,tableC tc 
         where tb.m=tc.m 
      group by tb.a,tc.b;
      

  5.   

    --再试一下:Insert into A表(a,b,c,d)
           select tab.f1,tab.f2,tab.f3,to_date('20081101 110000','yyyymmdd hh24miss')
                  from (Select B表.a f1,C表.b f2,A表.d,count(*) f3 
                              From A表,B表,C表 
                                  Where B表.m=C表.m 
             Group by B表.a,C表.b,A表.d) tab;
      

  6.   

    我把题目简化了:按B表的字段1数据分组,把A表的字段3填一个固定值。A表的字段1,字段2分别填B表.字段1,和符合分组条件的数据条数
    如下:对不对? 
    Insert into A表(字段1,字段2,字段3) 
    Select B表.字段1,Count(*), to_date('20081101 110000','yyyymmdd hh24miss') 
    From B表 
    Group by B表.字段1