Problem in «Insert into...» "Select * from tablename" query

Hello
I am inserting a million record from one table to another table using "insert in...". Select * from 'method. During this insertion, if one of the recording have insertion any problem then obiviously, be rollbacked, - not only that, to find the wrong people, the recording will be a tedious job.

is it possible to find which record having problems during such an insertion? and is it possible to validate the transaction?

Note: I know that we can use the collection method in bulk to solve this problem, but my situation, I have to use "insert..." Select * from 'method only.

Please guide me if anyone have dealt with this problem before.

Thank you
Kalanidhi

You can try the ERROR LOG IN the clause of the INSERT statement.

Tags: Database

Similar Questions

  • Insert into select * from table 3. -is on the agenda by the needless?

    I've got an example of script, it will work for any table, so I don't bother with the full ddl.

    ----------------------------------------------------------------------------
    create table test in select * from hotels where 1 = 2;

    Insert into test select * from Hotels by city;

    Select the city from the trial;

    -drop table test is serving;
    -----------------------------------------------------------------------------

    The amazing thing is, that the city is ordered alphabetically,
    but you would say it is that an operation order is irrelevant.

    Any ideas on that?

    This will still work?

    Edited by: FourEyes on December 8, 2008 22:55

    Edited by: FourEyes on 8 December 2008 22:56

    Edited by: FourEyes on 8 December 2008 22:56

    Hello

    The [SQL Oracle 10 language reference | http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_9014.htm#sthref9371] manual says:

    «In regards to the ORDER BY clause from the subquery in the DML_table_expression_clause, you place your order is guaranteed only for the inserted rows and only within each extension table.» Orders new lines with regard to existing lines is not guaranteed. »

  • Insert into table1 from table1

    Hello

    I tried to insert into table - from select col1, col2, col3 from table b where
    Table - b.change_dt between 't1d' and 'T2D.

    can someone help me with the query

    Thank you
    insert into table-A from select col1,col2,col3 from table-b where
    table-b.change_dt between 'dt1' and 'dt2'
    

    you have an additional 'from', so it will be:

    insert into table-A(col1,col2,col3) (select col1, col2, col3 from table b where)
    Table - b.change_dt between 't1d' and "T2D")

    Please, close your threads, try to clean up the forum.

  • issue: sql insert into select

    which is wrong with this query?

    insert into m_payment_option (p_type, m_fulfillment)

    values ('DIRECT_DEBIT', (select id from M_FULFILLMENT whose id not in (select m_fulfillment from M_PAYMENT_OPTION)));

    SQL-Fehler: ORA-01427: Unterabfrage fur eine liefert mehr als eine line line

    01427 00000 - "einreihig subquery returns several lines.

    the subquery returns:

    SELECT id from M_FULFILLMENT whose id not in (select m_fulfillment from M_PAYMENT_OPTION)

    47113

    47182

    47183

    ..

    Hallo,

    Try this

    insert into m_payment_option (p_type,m_fulfillment)
    select 'DIRECT_DEBIT', id from M_FULFILLMENT  where id not in (select m_fulfillment from M_PAYMENT_OPTION));
    

    The subquery in your statement offers several lines and failed to insert 2 or more values in your m_fulfillment column at a time.

    But I think you want to insert several lines. Otherwise, you need to change your subquery to offer that one value, maybe a max or min function will help.

    Grüße aus Bonn

    Kay

  • CAPTURE THE OUTPUT IN INSERT INTO SELECT AND DELETE

    Hi all


    INSERT into employee_history_arch select * from employee_history where employee_status = 'CP' and action_dt < (sysdate-32);
    commit;

    delete from employee_history where employee_status = 'CP' and action_dt < (sysdate-32);
    commit;

    I must capture both the output of the insert and delete the sql query and compare the two values for validation. I shouldn't use select count (*) before the delete statement. I shud exactly capture the output... How to do? Please help me

    We will have ' 30 deleted rows' or ' 30 inserted rows"in our tool... I need to capture that 'put out' in a variable and validate against the other

    This should be easy.

    SQL> set serverout on
    SQL> DECLARE
      2    v_rows_inserted PLS_INTEGER;
      3    v_rows_deleted  PLS_INTEGER;
      4  BEGIN
      5    INSERT INTO emp_temp
      6      SELECT * FROM emp WHERE deptno = 20;
      7    v_rows_inserted := SQL%ROWCOUNT;
      8    dbms_output.put_line('Rows Inserted: ' || v_rows_inserted);
      9    DELETE FROM EMP WHERE deptno = 20;
     10    v_rows_deleted := SQL%ROWCOUNT;
     11    dbms_output.put_line('Rows Deleted: ' || v_rows_deleted);
     12    IF v_rows_inserted = v_rows_deleted THEN
     13      dbms_output.put_line('They are same!');
     14    ELSE
     15      dbms_output.put_line('They are NOT same!');
     16    END IF;
     17  END;
     18  /
    Rows Inserted: 7
    Rows Deleted: 7
    They are same!
    
    PL/SQL procedure successfully completed.
    
  • Problem to INSERT INTO using the stored procedure in 10g

    I use a 10g R2 database.

    I created two tables as follows:
    SQL > create table t1 (c1 varchar2 (1), number (1) c2, c3 number (1);)
    SQL > create table t2 (deptid varchar2 (4), empid varchar (4), varchar2 (1) c1, c2 number (1) c3 number (1);)

    insert into t1 values ('A', 3, 5);
    insert into t1 values ('B', 5, 5);
    insert into t1 values ('C', 5, 5);

    I want to create a stored procedure to insert data into table t1 t2 and certain parameters of the procedure.
    Is this possible?
    As an example:
    SQL > execute test (1,2)

    This procedure will be insert these two parameters in table t2 AND select rows in table t1 and insert into table t2 at the same time.
    How can I write the procedure?
    Tip:
    SQL > create or replace procedure
    (v_deptid, v_empid number)
    is
    BEGIN
    Insert into t2 (deptid, empid, c1, c2, c3)
    ... Select c1, c2, c3 from t1;
    end;

    My question is: How can I insert the v_deptid and v_empid parameters at the same time?

    Try

    SQL > create or replace procedure
    (v_deptid, v_empid number)
    is
    BEGIN
    Insert into t2 (deptid, empid, c1, c2, c3)
    Select v_deptid, v_empid, c1, c2, c3 to t1;
    end;

  • Function of package of call per line in the statement INSERT INTO SELECT

    Hello

    I wrote the following SQL insert.

    INSERT the Table_A (Col_A, Col_B, Col_C)

    SELECT Col_A, Col_B, (SELECT PACKAGE1. DOUBLE FUNC())

    FROM Table_A

    WHERE Col_A = "AAA".

    PACKAGE1. Func() is a function to create numbers using the sequence.

    The result is

    Col_a Col_B, Col_C

    ---------------------------------------

    C003 AAA B1

    C003 AAA B2
    C003 AAA B3

    What I want is as follows:

    Col_a Col_B, Col_C

    ---------------------------------------

    C003 AAA B1

    AAA B2 C004
    AAA B3 C005

    I want different values per line in Col_C. is it possible to do this?

    I think the fact that you put the function call in a subquery is why he executed only once (which is a useful thing to know if you want this feature). To get executed for each line, you only need to do this:

    INSERT the Table_A (Col_A, Col_B, Col_C)

    SELECT Col_A, Col_B, PACKAGE1. FUNC()

    FROM Table_A

    WHERE Col_A = "AAA".

    However, as others have said, there is no reason to wrap a sequence.nextval in a function.

  • Problem with 'insert into array.

    First of all, sorry for my English.

    I have a problem with this function, I want to insert an item in the table of size 16 based on the index, but when I insert an element in position 4 (for example) and then I insert another element at position 2, the element that was at position 4 is moved to position 5, and I have no why understan

    Can you help me? Thank you

    Table Insert will increase the size of the table and therefore all which comes after your insert index will be its index increased by the number of items you enter.

    If you want to replace an item in a table - use "replace the subset of the table.

    Here is an example:

    Output:

  • Long time, buffer with an insert and select through a dblink

    I do a fairly simple ' insert into select from "statement through a dblink, but something is seriously wrong across the link. I am a huge buffer time in terms of the command explain (line 9) and I don't know why. When I try to run sql tuning on it across the dblink, I get an ora-600 error "ORA-24327: need explicit attach before authenticating a user.
    Here's the original sql:

    INSERT INTO PACE_IR_MOISTURE@PRODDMT00 (SCHEDULE_SEQ, LAB_SAMPLE_ID, HSN, SAMPLE_TYPE, MATRIX, SYSTEM_ID)
    SELECT DISTINCT S.SCHEDULE_SEQ, PI. LAB_SAMPLE_ID, PI. HSN, SAM. SAMPLE_TYPE, SAM. MATRIX: B1 S SCHEDULES
    JOIN THE PERMANENT_IDS ' X '. HSN = S.SCHEDULE_ID
    JOIN SAM SAMPLES WE PI. HSN = SAM. HSN
    JOIN PROJECT_SAMPLES ON PS PS. HSN = SAM. HSN
    JOIN PROJECTS P ON PS. PROJECT_SEQ = PS. PROJECT_SEQ
    WHERE S.PROC_CODE = 'DRY WEIGHT' AND S.ACTIVE_FLAG = 'C' AND S.COND_CODE = 'CH' AND P.WIP_STATUS IN ('WP', 'HO')
    AND SAM. WIP_STATUS = "WP";

    Here's the sql code, as it appears on proddmt00:

    INSERT INTO 'PACE_IR_MOISTURE' ('SCHEDULE_SEQ', 'LAB_SAMPLE_ID', 'HSN","SAMPLE_TYPE","MATRIX","SYSTEM_ID")
    SELECT 'A6' DISTINCT '. SCHEDULE_SEQ', 'A5 '. "' LAB_SAMPLE_ID ', 'A5 '. "" HSN ","A4 ". "" SAMPLE_TYPE ","A4 ". "" MATRIX ": B1
    "SCHEDULES" @! "A6", "PERMANENT_IDS" @! "A5", "SAMPLES" @! "A4", "PROJECT_SAMPLES" @! "A3", "PROJECTS" @! "A2".
    WHERE "A6". «PROC_CODE ' = 'DRY WEIGHT' AND 'A6'.» ' ACTIVE_FLAG '= 'C' AND "A6". "COND_CODE" = "CH", ("A2" ".") " WIP_STATUS '= 'WP' OR 'A2'.' WIP_STATUS "=" HO") AND"A4 ". "WIP_STATUS"= "WP" AND "A3". "PROJECT_SEQ"= "A3". "" PROJECT_SEQ "AND"A3 ". "HSN"= "A4". "" HSN ' AND 'A5 '. "HSN"= "A4". "" HSN ' AND 'A5 '. "HSN"= "A6". "" SCHEDULE_ID. "

    Here is the plan of the command explain on proddmt00:

    PLAN_TABLE_OUTPUT
    ------------------------------------------------------------------------------------------------------------------------------------------------------
    SQL_ID, cvgpfkhdhn835, number of children 0
    -------------------------------------
    INSERT INTO 'PACE_IR_MOISTURE' ('SCHEDULE_SEQ', 'LAB_SAMPLE_ID', 'HSN","SAMPLE_TYPE","MATRIX","SYSTEM_ID")
    SELECT 'A6' DISTINCT '. SCHEDULE_SEQ', 'A5 '. "' LAB_SAMPLE_ID ', 'A5 '. "" HSN ","A4 ". "" SAMPLE_TYPE ","A4 ". "" MATRIX ": B1
    "SCHEDULES" @! "A6", "PERMANENT_IDS" @! "A5", "SAMPLES" @! "A4", "PROJECT_SAMPLES" @! "A3", "PROJECTS" @! "A2".
    WHERE "A6". «PROC_CODE ' = 'DRY WEIGHT' AND 'A6'.» ' ACTIVE_FLAG '= 'C' AND "A6". "COND_CODE" = "CH" AND "
    ("A2". "WIP_STATUS"= "WP" OR "A2". ("" WIP_STATUS "=" HO ") AND"A4 ". "WIP_STATUS" = "WP" AND "
    "A3". "PROJECT_SEQ"= "A3". "" PROJECT_SEQ "AND"A3 ". "HSN"= "A4". "" HSN ' AND 'A5 '. "HSN"= "A4". "" HSN "AND
    'A5 '. "HSN"= "A6". "" SCHEDULE_ID. "

    Hash value of plan: 3310593411

    -------------------------------------------------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | TempSpc | Cost (% CPU). Time | Inst | IN-OUT |
    -------------------------------------------------------------------------------------------------------------------
    | 0 | INSERT STATEMENT. 5426M (100) | |
    | 1. UNIQUE HASH | 1210K | 118 M | 262 M | 5426M (3) | 999:59:59 |
    |* 2 | HASH JOIN | 763G | 54T | 8152K | 4300M (1) | 999:59:59 |
    | 3. DISTANCE | 231K | 5429K | 3389 (2) | 00:00:41 |! | R > S |
    | 4. THE CARTESIAN MERGE JOIN. 1254G | 61T | 1361M (74). 999:59:59 |
    | 5. THE CARTESIAN MERGE JOIN. 3297K | 128 M | 22869 (5) | 00:04:35 |
    | 4 > DISTANCE | SCHEDULES | 79. 3002 | 75 (0) | 00:00:01 | | R > S |
    | 7. KIND OF BUFFER. 41830 | 122K | 22794 (5) | 00:04:34 |
    | 8. DISTANCE | PROJECTS | 41830 | 122K | 281 (2) | 00:00:04 |! | R > S |
    | 9. KIND OF BUFFER. 380K | 4828K | 1361M (74). 999:59:59 |
    | 10. DISTANCE | PROJECT_SAMPLES | 380K | 4828K | 111 (0) | 00:00:02 |! | R > S |
    -------------------------------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):
    ---------------------------------------------------

    2 - access("A3".") HSN '= 'A4'.' HSN' AND 'A5 '. "HSN"= "A6". ("' SCHEDULE_ID")

    Hello

    Looking at your SQL it loks like you're not joining to the PROJECT table (where the word dreaded CARTESIAN?):

    Your code:

    JOIN PROJECTS P ON PS.PROJECT_SEQ = PS.PROJECT_SEQ 
    

    ... I think this should probably be...

    JOIN PROJECTS P ON P.PROJECT_SEQ = PS.PROJECT_SEQ 
    

    ....??

  • Insert into MDQ_OLD select * from table (lt_monitorMdq);

    I'm trying to insert into a table that has only a single column, which is a column of a user defined type (UDT). The UDT is nested, that is one of the attributes of the UDT is an another UDT.

    I aim to insert into the table like this pseudo-code:

    INSERT INTO T1 SELECT * FROM THE UDT;

    CREATE TABLE MDQ_OLD (myMDQ UDT_T_MONITOR_MDQ)

    NESTED TABLE myMDQ

    (T1_NEW) ACE STORE

    THE NESTED TABLE MONITOR_MDQ_PRIM_RIGHTS

    STORE AS T2_NEW);

    The MONITOR_MDQ_CLI procedure. Read below returns the parameter lt_monitorMdq which is a UDT type as announced. The statement "insert into select MDQ_OLD * table (lt_monitorMdq);" fails, while the second insert statement works.

    Is it possible to get the first statement of work?

    I'm on Oracle 11 g 2.

    DECLARE

    lt_monitorMdq UDT_T_MONITOR_MDQ;

    BEGIN

    MONITOR_MDQ_CLI. Reading (TRUNC (SYSDATE),

    TRUNC (SYSDATE),

    NULL,

    NULL,

    "MILLION BTU.

    lt_monitorMdq); -Note lt_monitorMdq is an OUT parameter

    -This insert does not work

    Insert into MDQ_OLD select * from table (lt_monitorMdq);

    BECAUSE me in 1... lt_monitorMdq.count

    LOOP

    Dbms_output.put_line ('lt_monitorMdq: ' | .mdq_id lt_monitorMdq (i));

    -This integration works

    INSERT INTO MDQ_OLD (MYMDQ)

    VALUES (UDT_T_MONITOR_MDQ (UDT_R_MONITOR_MDQ)

    lt_monitorMdq (i) .gasday,

    1,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    () UDT_T_MONITOR_MDQ_PRIM_RIGHT

    () UDT_R_MONITOR_MDQ_PRIM_RIGHT

    1,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    NULL,

    (NULL)));

    END LOOP;

    END;

    have you tried:

    INSERT INTO MDQ_OLD (myMDQ) VALUES (lt_MonditorMDq);

    curiosity:

    Is there a particular reason, why you have created a table with a single column of type UDT instead of:

    CREATE TABLE... OF UDT_T_MONITOR_MDQ;

    I can tell you from experience that using a nested table, you can easily query the data in the nested table.

    MK

  • Support for mandatory request - insert, select from the same table

    Hi all

    I need your help to write queries effectively.
    Oracle Version: 10.2.0.3.0
    OPERATING SYSTEM: UNIX

    I have a METRICS_TBL that is mentioned below table.

    CYCLE_DATE METRIC VALUE
    08/17/2008 COST-TV 100
    08/17/2008 COST-JOURNAL 50
    08/17/2008 COST-POSTALMAIL 25
    08/17/2008-PROD-TV 10
    08/17/2008-PROD-JOURNAL 25
    08/17/2008-PROD-POSTALMAIL 5

    Any data above, I have to add (Insert into select METRICS_TBL METRICS_TBL) at the same table with the records as mentioned below.

    2008-08-17 COSTPERPROD-TV 10
    08/17/2008-COSTPERPROD-LOG 2
    2008-08-17 COST PROD-POSTALMAIL 5

    Basically, I need to calculate the cost per product for each category. Depending on the settings available, metric should also be changed as COSTPERPROD and values should be cost/prod under each category.

    Can someone help me with the query.

    Thank you

    Something like this:

    INSERT INTO metrics_tbl
    (cycle_date, metrics, value)
    SELECT cost.cycle_date
             , 'COSTPERPROD-'||cost.mtype
             ,cost.value / prod.value
    FROM  (
       select cycle_date,substr(metrics, 1, 4) mtype, substrmetrics,instr(metrics,'-')+1) mmetric
       where substr(metrics, 1, 4) = 'PROD'
       ) prod
    INNER JOIN (   select cycle_date,substr(metrics, 1, 4) mtype, substrmetrics,instr(metrics,'-')+1) mmetric
       where substr(metrics, 1, 4) = 'COST'
       ) cost on cost.cycle_date = prod.cycle_date and cost.mmetric = prod.mmetric
    

    Ideally you would divide your METRICS column into two: one for the thing you're measuring (e.g. TV or NEWSPAPER) and the other for the metric (COST, PROD, COSTPERPROD etc.). That's what I did in the views online. Without it, it's kinda a mess and behave so, if the table becomes much more.

    HTH

    Nigel cordially

    Edited by: nthomas on January 14, 2009 15:57 - small correction SQL

  • Exception No_data_found to insert into... select statement

    Hai,
    I have a doubt in plsql exceptions. In the sub program mentioned plsql.

    Start

    insert into select abc * xyz a, b of cdf where a.c1 = b.c2;

    exception
    When no_data_found then
    do some operations

    end;

    In the pl/sql block above, if the select statement returns no rows, whether or not the exception is triggered? If not, how do the same. Any available alternative.

    Thanks in advance.

    Concerning
    Sridhar

    You would get an error no_data_found triggered at that time there, because it's perfectly valid to insert rows 0.

    You will need to check SQL ROWCOUNT % and raise the no_data_found if it is equal to 0.

  • Insert XML data from the Table-&gt; back to null

    Dear Experts,

    -I have table xml as below:

    Example of CREATE TABLE (XML_spec XMLTYPE);

    Insert in the example
    Select ' < name of Message = "dataStaticInvestor" type = "IncomingMessage" >
    < name of field = "batchReference" > OPENINGBATCH000000 < / field > < List name = "data" >
    < = record name "data" >
    < name of field = "externalReference" > 01234567890aaaaaaa < / field >
    < name of field = "participantID" > OD001 < / field >
    < name of field = "participantName" > EQUITY SECURITIES INDONESIA, PT < / field >
    < / recording >
    < = record name "data" >
    < name of field = "externalReference" > 01234567890aaaaaaa < / field >
    < name of field = "participantID" > OD001 < / field >
    < name of field = "participantName" > EQUITY SECURITIES INDONESIA, PT < / field >
    < / recording >
    < = record name "data" >
    < name of field = "externalReference" > 01234567890aaaaaaa < / field >
    < name of field = "participantID" > OD001 < / field >
    < name of field = "participantName" > EQUITY SECURITIES INDONESIA, PT < / field >
    < / recording >
    < / list >
    < / message > ' double.

    Select * example;

    create table hasil1 (c1 varchar2 (500), c2 varchar2 (500), c3 varchar2 (500));

    -This step I create the procedure to insert xml data into the table as the batch.

    DECLARE
    x XmlType;
    BEGIN
    Select XML_SPEC in x for example;

    insert into hasil1
    SELECT
    p.Extract('/Record/Field/@externalReference').getstringval (C1),
    p.Extract('/Record/Field/@participantID').getstringval (C2),
    p.Extract('/Record/Field/@participantName').getstringval () as c3
    TABLE (XMLSequence (Extract(x,'Message/List/Record'))) p;
    commit;
    END;
    /

    -when the result of select hasil1, the output is back 3 rows and 3 columns, but all data is a null *.

    Best regards
    Sigcle

    You don't explain what output you need, but I guess something like this:

    SQL> insert into hasil1 (c1, c2, c3)
      2  select x.c1, x.c2, x.c3
      3  from example t
      4     , xmltable(
      5         'Message/List/Record'
      6         passing t.xml_spec
      7         columns c1 varchar2(500) path 'Field[@name="externalReference"]'
      8               , c2 varchar2(500) path 'Field[@name="participantID"]'
      9               , c3 varchar2(500) path 'Field[@name="participantName"]'
     10       ) x
     11  ;
    
    3 rows inserted
    
    SQL> select * from hasil1;
    
    C1                     C2        C3
    ---------------------- --------- --------------------------------
    01234567890aaaaaaa     OD001     EQUITY SECURITIES INDONESIA,PT
    01234567890aaaaaaa     OD001     EQUITY SECURITIES INDONESIA,PT
    01234567890aaaaaaa     OD001     EQUITY SECURITIES INDONESIA,PT
     
    
  • How to get data in the procedure after CREATE TABLE table1 AS SELECT * from table2

    Hello

    can any body tell me how to get the data in the new table created in the procedure. because it gives following error.

    • Error (47,21): PL/SQL: ORA-00942: table or view does not exist

    tableName: = "BCKUP_" | TO_CHAR (sysdate, 'ddmmrrrr');

    tableDDL: = 'CREATE TABLE' | tableName. "AS SELECT * FROM Table1 where to_char(MSG_IN_TIME,''dd-mon-rrrr'') < sysdate - ' | daysNumber;

    EXECUTE IMMEDIATE backUpDDL;

    COMMIT;

    DELETE FROM Table1;

    How to select the data in the newly created table. as...

    Select * from ". tableName;

    Do not choose anything to get the number...

    Just after backupDDL EXECUTE IMMEDIATE, simply refers to SQL % ROWCOUNT - who will be the number of lines.

    Oh and DDL engages automatically, your commitment is redundant.

  • missing parenthesis in insertion into separate lines select the table from the other table

    Hello

    could you help me with the following question?

    I have the following tables

    CREATE TABLE table1)

    ID varchar (12),

    col2 varchar (10),

    COL3 varchar (10),

    level varchar (10))

    CREATE TABLE table2)

    Id2 varchar (12)

    A varchar (10),

    B number (1)

    CONSTRAINT PRIMARY KEY PK (ID2, is));

    INSERT INTO table2 (ID2, A, B) SELECT ID, col2

    MAX (CASE WHEN level = "level 1" then 1

    level = 'level 2' then 2

    Level = 3 then 'niveau3') as colIN3)

    FROM table1 GROUP BY ID2, a.;

    the first table have duplicates as follows:

    Id2 COL2 COL3 level

    A1 pepe football level1

    A1 pepe football level2

    A1 pepe football level1

    A1 pepe basket level2

    A1 pepe pingpong level3

    the output should be selected with unique key (ID2, col3) lines and the level must be the greatest.

    Id2 COL2 COL3 level

    A1 pepe football level2

    A1 pepe basket level2

    A1 pepe pingpong level3

    The output of the script tells me the following messages:

    -lack of right parenthesis referring to the max function.

    Thanks adavance.

    Kind regards

    Hello

    Remember the ABC's of the GROUP BY:

    When you use a GROUP BY clause or in an aggregate function, then all in the SELECT clause must be:

    (A) a ggregate function,

    (B) one of the expressions "group By."

    (C) adding to C, or

    (D) something that Depends on the foregoing.  (For example, if you "GROUP BY TRUNC (dt)", you can SELECT "TO_CHAR (TRUNC (dt), 'Mon - DD')").

    To ask him, there are 5 columns in the SELECT clause.  The last one is a function MAX (...); It is an aggregate, is not serious.

    The first 2 columns are also named in the GROUP BY clause, so that they are well.

    The other 2 columns, country and internal_Id do not match any of the above categories.  These 2 columns cause the error.

    There are many ways to avoid this error, each producing different results.  You could

    • remove these 2 columns in the SELECT clause
    • Add these 2 columns in the GROUP BY clause
    • use the aggregation such as MIN, 2-column functions
    • remove the country from the SELECT clause and add internal_id to the GROUP BY clause
    • remove the internal_id from the SELECT clause, and add countries to the GROUP BY clause
    • ...

    What are the results you want?

    Whenever you have a question, please post a small example of data (CREATE TABLE and INSERT statements) for all the tables involved, so people who want to help you can recreate the problem and test their ideas.  Also post the results you want from this data, as well as an explanation of how you get these results from these data.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002

Maybe you are looking for