Insert into select

i have following query but no idea how to put this into “insert into select” statement.I want to convert following quert into insert into select.Any one have idea. Ihave given partial query.

WITH time_summary_data
          AS (  SELECT   name,
                         id,
                         event_id,
                                         MAX (d_time_to) d_time_to,
                                                 MAX (e_time_to) e_time_to,
                                                   i_time_from
              FROM   (SELECT   *
                            FROM   (SELECT   b.name,
                                             aid,
                                             a.event_id,
                                             a.activity_phase,
                                             a.activity_code,
                                             'D' phase_ind,
                                          
                                             a.time_to d_time_to,
                                           
                                             NULL e_time_to,
                                            
                                             NULL i_time_from,
                                             --   null        i_time_to,
                                            
                                                OVER (
                                                   PARTITION BY a.edm_well_id,
                                                                a.event_id
                                                )
                                                max_time_to
                                      FROM      time_summary a
                                             INNER JOIN

Even if your query has a initial with clause it is still a select statement, i.e.

INSERT INTO table_name WITH time_summary_data
          AS (  SELECT   name, ....

is valid sql.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.