insert into  stateovh.safe_d_check_result_main A(SUM_Problem,SUM_KeyProblem) 
Select b.SUM_Problem,B.SUM_KeyProblem 
From (Select RESULT_MAIN_ID,NVL(Sum(ost_problem_num),0) AS SUM_Problem,NVL(SUM(ost_keyproblem_num),0)AS SUM_KeyProblem 
      From stateovh.safe_d_check_result_sum 
      WHere ost_problem_num>0
      Group BY RESULT_MAIN_ID) B
Where B.RESULT_MAIN_ID=A.RESULT_MAIN_ID上面语句有错 A.RESULT_MAIN_ID无效进行insert into 要让查询出的数据的 RESULT_MAIN_ID与主表的RESULT_MAIN_ID相等,这样对应的插入,而不是乱插一气,七荤八素的都进去请帮忙给出可执行的正确语句 3Q

解决方案 »

  1.   

    什么意思,没看懂
    insert into tablename(col1,col2) select col1,col2 from tablename
      

  2.   

    insert into  stateovh.safe_d_check_result_main (SUM_Problem,SUM_KeyProblem)
    Select b.SUM_Problem,B.SUM_KeyProblem
    From (Select RESULT_MAIN_ID,NVL(Sum(ost_problem_num),0) AS SUM_Problem,NVL(SUM(ost_keyproblem_num),0)AS SUM_KeyProblem
          From stateovh.safe_d_check_result_sum
          WHere ost_problem_num>0
          Group BY RESULT_MAIN_ID) B,stateovh.safe_d_check_result_main A
    Where B.RESULT_MAIN_ID=A.RESULT_MAIN_ID 
    不知道你是不是这个意思