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

Tags: Database

Similar Questions

  • Insert a blank line in the result set

    Hi friends,

    SELECT * FROM EMPLOYEES ORDER BY DEPARTMENT_ID;

    As a result of the foregoing, I need to INSERT a blank line in the result for each department_id. for example, the result should resemble the following:

    EMP_ID - NAME - SALARY - DEPARTMENT_ID
    101 - Albert - 10 000 - 10
    102 - Benjamin - 8 000 - 10

    103 - Chitra - 10 500 - 20
    104 - David - 4 500-20
    105 - Elango - 6 000 - 20

    106 - faye - 6 000 - 30
    107 - Ganga - 9 000 - 30

    etc.

    I don't want to insert into the table. I need a blank line just on the screen.

    Thanks in advance.

    Published by: James on March 8, 2010 11:37

    Something like this->

    satyaki>
    satyaki>select * from v$version;
    
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE    11.1.0.6.0      Production
    TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production
    
    Elapsed: 00:00:00.00
    satyaki>
    satyaki>
    satyaki>select m.empno,
      2         m.ename,
      3         m.sal,
      4         case
      5           when sal is null
      6           and  empno is null
      7           and  ename is null then
      8             null
      9         else
     10           m.deptno
     11         end deptno
     12  from (
     13        select k.empno,
     14              k.ename,
     15              k.sal,
     16              k.deptno
     17        from (
     18                select empno,
     19                             ename,
     20                             sal,
     21                             deptno
     22                from emp
     23            ) k
     24        union all
     25        select t.*
     26        from (
     27                select distinct null empno, null ename, null sal, deptno
     28                from emp
     29            ) t
     30        order by 4
     31      ) m;
    
         EMPNO ENAME             SAL     DEPTNO
    ---------- ---------- ---------- ----------
          7782 CLARK            2450         10
          7839 KING             5000         10
          7934 MILLER           1300         10
    
          7566 JONES            2975         20
          7369 SMITH             800         20
    
          7902 FORD             3000         20
          7876 ADAMS            1100         20
          7788 SCOTT            3000         20
    
         EMPNO ENAME             SAL     DEPTNO
    ---------- ---------- ---------- ----------
          7900 JAMES             950         30
          7499 ALLEN            1600         30
          7844 TURNER           1500         30
          7654 MARTIN           1250         30
          7521 WARD             1250         30
          7698 BLAKE            2850         30
    
    17 rows selected.
    
    Elapsed: 00:00:00.03
    satyaki>
    satyaki>
    

    Kind regards.

    LOULOU.

  • We can insert a new line at the end of af: table declaratively?

    Mr President.

    We can insert a new line at the end of af: table declaratively?

    Concerning

    In the t impl class substitution as below, after that, you should be able to insert at the end of the table.

    @Override

    {} public void insertRow (rank)

    Line lastRow = this.last ();

    If (lastRow! = null) {}

    int j = this.getRangeIndexOf (lastRow) + 1;

    this.insertRowAtRangeIndex (j, line);

    this.setCurrentRow (row);

    } else {}

    super.insertRow (row);

    }

    }

  • Question: insertion of several lines in the MS Sql Server table using the DB adapter

    Hi all

    I managed to insert a single row in a table of MS SQL Server via the adapter DB to my process BPEL, but when I tried to insert in mutiple lines in the same table of MS SQL server, I encounter the error below.

    I use a DB SQL XA connection to connect to the server.

    Kindly help me to solve the problem. Thanks in advance.

    Error:

    " < bpelFault > < faultType > 0 < / faultType > < remoteFault xmlns =" http://schemas.Oracle.com/BPEL/extension "> < a name ="summary"part > < summary > exemption is is produced when the binding was used." Exception occurred during invocation of the JCA binding: "JCA binding run 'merge' reference operations have to: DBWriteInteractionSpec Execute Failed Exception." the merger failed. The descriptor name: [LoadCmpAggSpendStage.SapTable]. Caused by com.microsoft.sqlserver.jdbc.SQLServerException: incorrect syntax near ')'... Check the logs for the record output full DBAdapter before this exception. This exception is considered as reproducible, probably due to a communication failure. To be classified as not reproducible rather add property nonRetriableErrorCodes with the '102' value in the deployment descriptor (i.e. weblogic - RA.Xml). Auto retry a reproducible fault set composite.xml for this invoke these properties: jca.retry.interval, jca.retry.count and jca.retry.backoff. All properties are integers. ". The called JCA adapter threw an exception of resource. Please examine the error message above carefully to determine a resolution. < /Summary. (> < / piece > < part name = "detail" > < detail syntax > incorrect near ')'. < / details > < / piece > < part name = "code" > < code > 102 < / code > < / piece > < / remoteFault > < / bpelFault >

    Kind regards

    Balaji Rahmani

    It seems that in this case is called merge operation. If existing records (check primary key) are not there then it will be inserted on the other update. Check the syntax of the query that is created. It looks like she may have a supplement "). If you want to only insert then call insert operation and not merge.

  • How to insert a new line in a table?

    I have a table of basic bit of lines and columns.

    In excel if I want to insert a blank line in the Middle, I just click right and do it.

    In DW, I am at a loss what to do. Thank you.

    It is very similar to the DW.  Right-click in a cell, and then click Table-> Insert a row or a column.  There is options to add several lines above or below.

  • 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 a blank line in the query output

    Is it possible to insert a blank line between two rows of the query output?

    In the EMP table, the column LINES is as follows:

    LINES
    1
    2
    3
    4
    1
    2
    3
    1
    2
    3
    4
    5

    I want to insert a blank line after every 1

    Please suggest.

    Sanjay

    I'm quite puzzled why you need rows in the dataset returned by a select statement that is empty.
    If you are using Oracle reports to the release date, you define the presentation of the report to have spaces between the rows returned by the select and have do not need to have the select statement returns a blank line after each line of data. If the output should be obtained by using another client, I think that the customer will have facilities for output formatting.

    Admit that you really need "blank lines" between data lines, I see only one way: use a temporary table and do an insert into select temporary_table (...) ... from... where... Then, in this temporary table, you can insert 'empty rows', which is actually not really empty, because they must have some fields that give the order of the rows. And then select in temporary_table, you place your order by the columns that are used to give the order for the release.
    Thus

    insert into temporary_table (
    ....
    )
    select ...
    from ...
    where ...
    ;
    for r in (
    select col1, col2, col3  -- columns used for order by
    from temporary_table
    order by col1, col2, col3
    )
    loop
      insert into temporary_table (col1, col2,col3, col4)
      values (r.col1,r.col2,r.col3, null);
    end loop;
    -- this way, a select * from temporary_tabel order by col1, col2, col3, col4 will return a blank row after each data row
    
  • How to insert a few lines of the user interface and some of the system during the click on the Add button

    Hi Experts ADF,

    I have an Add button and a table.

    My requirement is when the user clicks the Add button then the table below should show a new line. And some of the values I'm inserting into the method doDML with operation == DML_INSERT.

    I tried the steps below: -.

    (a) the primary key attribute is based on an expression groovy (with a sequence).

    (b) Add button is linked to the operation of CreateInsert.

    doDML c method) @Overridden in EOImpl, java. And some of the values I'm inserting into the method doDML with operation == DML_INSERT.

    (d) when I click Save I get error. So please let me know if any changes I need to do.

    Thank you

    Animesh

    Or if you want to insert data on the operation of createInsert then simply replace the create method in EOImpl

    Ashish

  • Double insert into, how to get the last insert id

    Hi all

    I need to insert some values into 2 tables, and on the second Board, I put the last id inserted in the first table. I actually did more the thing, but it does not work:

    insert into ADDRESS (id, street, neighborhood, zip code, city, idcountry, phonenumber, fax, phone, mail, post number) values (",", ",", ",", "," "," ");
    insert into samplecenter (ID, idaddress, samplecentername) values (", * IDENT_CURRENT ('ADDRESS') *,"GENERAL - CO");

    -What someone could help me.

    Thank you very much.
    Jarod.

    You must use a sequence.

    for example

    create sequence address_seq
    minvalue 1
    maxvalue 1000000000000000
    start with 1
    increment by 1
    nocache;
    
    insert into ADDRESS (id, street, area, zipcode, town, idcountry, phonenumber, faxnumber, gsm, mail, post)
      SELECT
             address_seq.NEXTVAL,'','','', '', '', '', '', '', '', ''
        FROM dual;
    
    insert into samplecenter (ID, idaddress, samplecentername) values ('',address_seq.CURRVAL,'GENERALE - CO');
    
  • Separate lines of two tables related by a third

    Hello

    I need to write a sentence SQL of a group of SEPARATE lines, each line in a shape of: A.X, A.Y, C.IDBOLETA. Tables A and C are related through the table C, as follows:

    Table A: INDUSTRIAGEO

    VARCHAR2 (20) NIT NOT NULL,.
    CORRELAIGEO NUMERIC (2) NOT NULL,
    NOMBREAGENCIA VARCHAR2 (255) NOT NULL,
    DIRECCION VARCHAR2 (255),
    X NUMERIC (12.8) NOT NULL,
    IS NUMERIC (12.8) NOT NULL,
    CONSTRAINT PKGEOINDUST PRIMARY KEY (NIT, CORRELAIGEO),
    CONSTRAINT FKGEOINDUST FOREIGN KEY (NIT) REFERENCES INDUSTRIA (NIT)

    Table B: ANÁLISIS

    IDANALISIS NUMERIC (12) NOT NULL,
    VARCHAR2 (20) NIT NOT NULL,.
    CORRELAIGEO NUMERIC (2) NOT NULL,
    DATE DATE NOT NULL,
    IDINSPECTOR NUMERIC (4) NOT NULL,
    CONSTRAINT PKANALISIS PRIMARY KEY (IDANALISIS).
    CONSTRAINT FKANALGEOI FOREIGN KEY (NIT, CORRELAIGEO) REFERS TO INDUSTRIAGEO (NIT, CORRELAIGEO).
    CONSTRAINT FKANALINSP FOREIGN KEY (IDINSPECTOR) REFERENCES INSPECTOR (IDINSPECTOR)

    Table c: ANALISISBOLETA

    IDANALISIS NUMERIC (12) NOT NULL,
    CORRELAANALISIS NUMERIC (2) NOT NULL,
    IDBOLETA NUMERIC (12) NOT NULL,
    IDCATEGORIAINDUSTRIA NUMERIC (3) NOT NULL,
    CONSTRAINT PKANALBOLE PRIMARY KEY (IDANALISIS, CORRELAANALISIS),
    CONSTRAINT UKANALBOLE UNIQUE (IDBOLETA).
    CONSTRAINT FKANALBOLE FOREIGN KEY (IDANALISIS) REFERENCES COPS. ANÁLISIS (IDANALISIS),
    CONSTRAINT FKANALCATI FOREIGN KEY (IDCATEGORIAINDUSTRIA) REFERENCES COPS. CATEGORIAINDUSTRIA (IDCATEGORIAINDUSTRIA)


    Thanks for your help!

    Mario

    Maybe

    select distinct a.x,a.y,c.idboleta
      from industriaego a,
           cops.analisis b,
           analisisboleta c
     where a.nit = b.nit
       and a.correlaigeo = b.correlaigeo
       and b.idanalisis = c.idanalisis
    

    Concerning

    Etbin

    Edited by: Etbin on 4.5.2010 21:42
    the Elf of copy/paste started: b.correlaigeo instead of b.a.correlaigeo (as in the comment of the OP below)

  • Word RTF Tem [plate - insert a blank line in the loop

    I'm entering my template like this XML data (this is just an example of dumbed down):

    <? XML version = "1.0"? >

    < LABEL_TEST >

    < LIST_G_TEST >

    < G_LABEL_HEADER >

    < NAME > Parent 1 < / NAME >

    < / G_LABEL_HEADER >

    < G_LABEL_HEADER >

    < NAME > Kid 1 < / NAME >

    < / G_LABEL_HEADER >

    < G_LABEL_HEADER >

    < NAME > Parent 2 < / NAME >

    < / G_LABEL_HEADER >

    < G_LABEL_HEADER >

    < NAME > Parent 3 < / NAME >

    < / G_LABEL_HEADER >

    < G_LABEL_HEADER >

    < NAME > 4 Parent < / NAME >

    < / G_LABEL_HEADER >

    < G_LABEL_HEADER >

    < NAME > Kid 4 < / NAME >

    < / G_LABEL_HEADER >

    < / LIST_G_TEST >

    < / LABEL_TEST >

    In summary, I have a list of Parents, and if they have a child, the name of their children is below. Not all parents have children.

    If the data is a bit like this:

    Name of the parent

    Name of the child

    Name of the parent

    Name of the parent

    Name of the parent

    Name of the child

    When I loop data in my RTF model, I want to be able to insert a blank line before all of the lines 'Parent '. A bit like this:

    Name of the parent

    Name of the child

    Name of the parent

    Name of the parent

    Name of the parent

    Name of the child

    I tried to do this by adding an empty xml tag in the list, like this:

    <? XML version = "1.0"? >

    < LABEL_TEST >

    < LIST_G_TEST >

    < G_LABEL_HEADER >

    < NAME > Parent 1 < / NAME >

    < / G_LABEL_HEADER >

    < G_LABEL_HEADER >

    < NAME > Kid 1 < / NAME >

    < / G_LABEL_HEADER >

    < G_LABEL_HEADER >

    < NAME > < / NAME >

    < / G_LABEL_HEADER >

    < G_LABEL_HEADER >

    < NAME > Parent 2 < / NAME >

    < / G_LABEL_HEADER >

    < G_LABEL_HEADER >

    < NAME > < / NAME >

    < / G_LABEL_HEADER >

    < G_LABEL_HEADER >

    < NAME > Parent 3 < / NAME >

    < / G_LABEL_HEADER >

    < G_LABEL_HEADER >

    < NAME > < / NAME >

    < / G_LABEL_HEADER >

    < G_LABEL_HEADER >

    < NAME > 4 Parent < / NAME >

    < / G_LABEL_HEADER >

    < G_LABEL_HEADER >

    < NAME > Kid 4 < / NAME >

    < / G_LABEL_HEADER >

    < / LIST_G_TEST >

    < / LABEL_TEST >

    But that doesn't seem to work.

    Manny

    I found a solution that works very well.

    I added a new XML field to my data called .  In my model, this field is inserted in the line, but in a location where there is no data being printed. And it is formatted as white text, so that it basically just does not appear.

    So essentially, it's what I have now:

    Parent 1

    .

    Child 1

    .

    .

    Parent 2

    .

    .

    Parent 3

    .

    .

    Mother 4

    .

    Child 4

    .

    If the data is a bit like this:

    The name of the parent.

    The name of the child.

    .

    The name of the parent.

    .

    The name of the parent.

    .

    The name of the parent.

    The name of the child.

    When I loop data in my RTF model, the '. ' is a white text, then I get this:

    Name of the parent

    Name of the child

    Name of the parent

    Name of the parent

    Name of the parent

    Name of the child

  • Divide the data into several lines in the table

    Hello

    I use apex of Oracle 10 g 3.2.

    I have a requirement like this.

    I have a table like TableA

    Col1 Col2
    90 1
    91 1:2:3
    92 3

    I want the data as

    Col1 Col2
    90 1
    91 1
    91 2
    91 3
    92 3

    How to do this?

    Thank you

    Published by: user13305573 on August 3, 2010 20:16
    with
       your_data as
    (
       select 90 as col1, '1'  as col2      from dual union all
       select 91, '1:2:3'   from dual union all
       select 92, '3'       from dual
    )
    select
       y.col1,
       regexp_substr(y.col2, '[^:]+', 1, t1.column_value) as col2
    from
       your_data y,
     13     table(cast(multiset(select level from dual connect by  level <= length (regexp_replace(y.col2, '[^:]+'))  + 1) as sys.OdciNumberList)) t1
     14  /
    
                  COL1 COL2
    ------------------ -----
                    90 1
                    91 1
                    91 2
                    91 3
                    92 3
    
    5 rows selected.
    
    Elapsed: 00:00:00.05
    ME_XE?select * from v$version;
    
    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    PL/SQL Release 10.2.0.1.0 - Production
    CORE     10.2.0.1.0     Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    
    5 rows selected.
    
    Elapsed: 00:00:00.03
    ME_XE?
    
  • SQL query * I want to insert a file column in the other table based on two columns

    I want to insert a column records to another table based on two columns

    the query below does not work

    insert into def_ver_lnki_p (job_name)

    Select def_job.job_name

    from def_job where def_job.job_id = def_ver_lnki_p.job_id and def_job.table_id = def_ver_lnki_p.table_id;

    Just to correct sql

    Update

    def_ver_lnki_p define job_name =)

    Select def_job.job_name

    of def_job

    where def_job.job_id = def_ver_lnki_p.job_id

    (and def_job.table_id = def_ver_lnki_p.table_id);

  • How to draw a line (with the line segment tool) then draw another line, from those previous anchor point. When I try immediately draw another line on the other anchor lines it try to turn instead.

    I'm following a course of basic fundamental illustrator on Lynda. The video of "draw straight lines" is troubling me. They draw a line with the line segment and then draw another line coming out the anchor point at an angle.

    Here's where it is troubling me - when I try to drag a line to the anchor point trying to transform the first line, I drew. (the line cursor turns into a selection tool) I can't draw another line connecting the first.

    Advice would be great because it's driving crazy me.

    See you soon,.
    Kyle

    Yes, it is irritating. You must clear the previous line first. If you want to make sure that both ends are perfectly aligned, start by turning on the guides. If you want two lines to be part of the same way, you should use the tool pen instead.

  • Automatic text of lines-placement of the table from one line to the other

    Hello

    can someone help me with a problem of formatting with tables;

    I would like to set up a table with multiple lines and the text automatically flow to the next line when you type once we're full... any help would be greatly appreciated

    Hey there,

    I just do the 1st rank.

    During the ENTIRE event, I changed the Javascript and insert the following code:

    xfa.host.setFocus(xfa.resolveNode("form1.#subform.Table1.Row3[1].Cell1"));
    
    Now it's working. You can do the rest.
    Tip: when coding, if you hold down Ctrl + Shift and click on any field, you get the name of the field instantly.
    Diego

Maybe you are looking for

  • ToolTips ceases to display after updating to firefox 11/12

    I'm on Ubuntu 11/12 and tooltips no longer works after that I updated to v11 or v12 of FF. I checked on various websites and ToolTips have stopped working. I checked about: config and it is. My extensions are: WOT; Tor-button; Flashblock; Ghostery; A

  • VeriFace Windows 10, not more :(

    Hi all, I was using veriface on windows 8.1 on my Yoga 2 13 and I was very satisfied. When I installed Windows 10, veriface disappeared. I thought it was because Windows has its own, but it's not. Is there anyway that I can reinstall veriface? Thanks

  • HTML HELP

    I installed a program created with Visual Foxpro 9 which has a compressed HTML Help file built with HTML Workshop on my Vista machine and selecting help in my menu or by pressing F1, the help file does not appear. I don't have this problem on my XP m

  • What should I do if my OST file is corrupt? I don't want to lose all my emails, attachments, etc. Can I use a third party software?

    Hello! Suddenly my OST file gets corrupted, yesterday while I was trying to connect to Exchange Server, I got an error like this: Then I searched the internet, and after much research I found the manual solution to create a new profile on the Exchang

  • PlayReady Pc Runtime amd64

    In simple terms what the exact function it does and if I'm not a gamer, should any purpose on my devices?