minimum hiredate from the emp table

Hello

There is a table EMP, hiredate column (date). I want to get the record with minimum hiredate and using this query.
SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE    10.2.0.4.0      Production
TNS for Solaris: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production

SQL> with t as
  2  (select 'A' ename, 1 enum, '1-Oct-2008' hiredate from dual union all
  3  select 'B', 2, '1-Jan-2002' from dual union all
  4  select 'C', 3, '1-Mar-2008' from dual)
  5  select * from t
  6  where hiredate = (select min(hiredate) from t);

E       ENUM HIREDATE
- ---------- ----------
B          2 1-Jan-2002

SQL> 
Is there another way to do it, without using subquery?

Kind regards
Ritesh

Another option:

SELECT  MIN(ENUM)       KEEP (DENSE_RANK FIRST ORDER BY HIREDATE)       AS ENUM
,       MIN(HIREDATE)   KEEP (DENSE_RANK FIRST ORDER BY HIREDATE)       AS HIREDATE
FROM    t

EDIT: See the post of John Spencer as it has a more in-depth explanation. This will only return the FIRST record oracle meets with minimal hiredate. It will not return more records if more than one employee has the same minimum hiredate.

Published by: Centinul on October 23, 2009 09:38

Tags: Database

Similar Questions

  • How can I get the second and third highest salary from the emp table

    How can I get the second and third highest salary from the emp table in the ecah Department
    SQL> ed
    Wrote file afiedt.buf
    
      1  select empno, ename, sal, deptno
      2  from (
      3    select empno, ename, sal, deptno, dense_rank() over (partition by deptno order by sal desc) as rn
      4    from emp
      5    )
      6* where rn in (2,3)
    SQL> /
    
         EMPNO ENAME             SAL     DEPTNO
    ---------- ---------- ---------- ----------
          7782 CLARK            2450         10
          7934 MILLER           1300         10
          7566 JONES            2975         20
          7876 ADAMS            1100         20
          7499 ALLEN            1600         30
          7844 TURNER           1500         30
    
    6 rows selected.
    
    SQL>
    
  • How to display data from the emp table?

    Hi everyone, this is my first post in this portal. I want to display the details of the table emp... for this I use this SQL statement.

    Select * from emp where mgr = nvl(:mgr,mgr);

    When I give the entry as 7698 it shows the matching records... and also when I don't give any input then it shows all the records except the Archbishop with null values.

    (1) I want to display all the records when I do not give any input, including null values
    (2) I want to display all the records that a Bishop is null

    Is it possible to integrate in order to include all these in a single query.

    Hello

    937440 wrote:
    Hi everyone, this is my first post in this portal.

    Welcome to the forum!
    Don't forget to read the forum FAQ {message identifier: = 9360002}

    I want to display the details of the table emp... for this I use this SQL statement.

    Select * from emp where mgr = nvl(:mgr,mgr);

    When I give the entry as 7698 it shows the matching records... and also when I don't give any input then it shows all the records except the Archbishop with null values.

    (1) I want to display all the records when I do not give any input, including null values
    (2) I want to display all the records that a Bishop is null

    Is it possible to integrate in order to include all these in a single query.

    It's a little unsure what you're asking.
    The following query always includes the lines where mgr is NULL and when the binding variable: mgr is NULL, it displays all the lines:

    SELECT  *
    FROM     emp
    WHERE     LNNVL (mgr != :mgr)
    ;
    

    In other words, when: 7698 = mgr, it displays 6 rows and when: mgr is NULL, it displays 14 rows (assuming you are using the table provided by Oracle scott.emp).

    The following query includes lines where Bishop is ZERO only when the binding variable: mgr is NULL, in which case it shows all lines:

    SELECT     *
    FROM     emp
    WHERE     :mgr     = mgr
    OR       :mgr       IS NULL
    ;
    

    When: mgr = 7698, this will display 5 rows and when: mgr is NULL, it displays 14 rows.

    The following query includes lines where Bishop is ZERO only when the link variab; e: mgr is NULL, in which case it shows only those rows where mgr is NULL. In other words, it treats NULL as a value:

    SELECT     *
    FROM     emp
    WHERE     DECODE ( mgr
                , :mgr, 'OK'
                )     = 'OK'
    ;
    

    When: mgr = 7698, this will display 5 rows and when: mgr is NULL, it displays 1 row.

  • XML from the Oracle Table data

    Hi all

    I'm new to this network. I'm also new to oracle XML package. I want a help with the query below.

    CREATE TABLE EMP (ID NUMBER PRIMARY KEY, NAME VARCHAR2 (10), TELEPHONE NUMBER);

    INSERT INTO EMP (ID, NAME, PHONE) VALUES (11, 'Joy', 1234);
    INSERT INTO EMP (ID, NAME, PHONE) VALUES (22, 'Mike', 5678).
    INSERT INTO EMP (ID, NAME, PHONE) VALUES (33, "Jason", NULL);
    COMMIT;

    I want to export data from the EMP table in an XML file with the format below.

    Power required:

    <? XML version = "1.0" encoding = "UTF-8"? > < Joy STATICDATA > < EMP > < ID > 11 < /ID > < NAME > < / NAME > < / EMP > < / STATICDATA >
    <? XML version = "1.0" encoding = "UTF-8"? > < Mike STATICDATA > < EMP > < ID > 22 < /ID > < NAME > < / NAME > < / EMP > < / STATICDATA >
    <? XML version = "1.0" encoding = "UTF-8"? > < Jason STATICDATA > < EMP > < ID > 33 < /ID > < NAME > < / NAME > < / EMP > < / STATICDATA >

    I used some XML functions and you wrote the following query.

    Select XMLROOT (XMLELEMENT (staticdata, XMLELEMENT (EMP, XMLELEMENT(ID,ID), XMLELEMENT(NAME,NAME))), version "1.0" encoding = "UTF - 8') xml EMP;

    my query output:

    <? XML version = "1.0" encoding = "UTF-8"? >
    < STATICDATA >
    < EMP >
    < ID > 11 / < ID >
    Joy of < NAME > < / NAME >
    < / EMP >
    < / STATICDATA >
    <? XML version = "1.0" encoding = "UTF-8"? >
    < STATICDATA >
    < EMP >
    < ID > 22 / < ID >
    < NAME > Mike < / NAME >
    < / EMP >
    < / STATICDATA >
    <? XML version = "1.0" encoding = "UTF-8"? >
    < STATICDATA >
    < EMP >
    < ID > 33 / < ID >
    Jason < NAME > < / NAME >
    < / EMP >
    < / STATICDATA >


    But I want the out as the power required above. all records in a single line. can someone help me achieve the desired output. also can I export all columns of the table with something like select * from the table in the XML file?

    Thank you
    Delobelle

    Don't know why you need it on a single line, but you could:

    Select XMLTYPE (REGEXP_REPLACE (XMLROOT (XMLELEMENT (staticdata, XMLELEMENT (EMP, XMLELEMENT(ID,ID), XMLELEMENT(NAME,NAME))), version "1.0" encoding = "UTF - 8'), CHR (10) |)) ' *<><'))>
    FROM EMP;

    SY.

  • How to insert 10,000 records test data into the emp table

    Hi I am new to oracle can someone please help me write a program so that I can insert the test data into the emp table
    SELECT       LEVEL empno,
                 DBMS_RANDOM.string ('U', 20) emp_name,
                 TRUNC (DBMS_RANDOM.VALUE (10000, 100000), 2) sal,
                 DBMS_RANDOM.string ('U', 10) job,
                 TO_DATE ('1990-01-01', 'yyyy-mm-dd')
                 + TRUNC (DBMS_RANDOM.VALUE (1, 6000), 0)
                   hiredate,
                 CASE
                   WHEN LEVEL > 10 THEN TRUNC (DBMS_RANDOM.VALUE (1, 11), 0)
                   ELSE NULL
                 END
                   mgr,
                 TRUNC (DBMS_RANDOM.VALUE (1, 5), 0) deptno
    FROM         DUAL
    CONNECT BY   LEVEL <= 10000
    
  • selecting max 5 salaries in the emp table

    Hi I tried the following query to obtain the emp table max 5 salaries...
    SQL> select sal
      2  from (select sal,empno from emp order by sal desc
      3  where rownum<6;
    
           SAL
    ----------
          5000
          3000
          3000
          2975
          2850
    But here in the output of the duplicate rows are there... I need to remove this and number total should be equal to only 5...
    If I put the distinct clause, then I'll take 4 rows only... but I need the salaries of the top 5...

    Thank you
    select *
      from (
    select distinct sal
      from emp
     order by sal desc
     ) where rownum <= 5
    ;
    
  • Select values from the db1 table and insert into the DB2 table

    Hello

    I have three databases oracle running in three different machines. their ip address is different. among the DB can access databases. (means am able to select values and insert values into tables individually.)

    I need to extract data from the DB1 table (ip say DB1 is 10.10.10.10 and the user is DB1user and the table is DB1user_table) and insert the values into DB2 table (say ip DB2 is 11.11.11.11 and the user is DB2user and table DB2user_table) of DB3 that is to have access to the two IPs DB.

    How do I do this

    Edited by: Aemunathan on February 10, 2010 23:12

    Depending on the amount of data must be moved between DB1 and DB2, and the frequency at which this should happen, you might consider the SQL * COPY more control. I think it's very useful for one-off tasks little, so I can live within its limits of the data type. More http://download.oracle.com/docs/cd/E11882_01/server.112/e10823/apb.htm#i641251.

    Change some parameter of sqlplus session are almost mandatory in order to get decent transfer rates. Tuning ARRAYSIZE and COPYCOMMIT can make a huge difference in flow. LONG change may be necessary, too, depending on your data. The documentation offers these notes on use:

    To activate the copy of data between Oracle and databases non-Oracle, NUMBER of columns is replaced by DECIMAL columns in the destination table. Therefore, if you are copying between Oracle databases, a NUMBER column with no precision will become a DECIMAL column (38). When copying between Oracle databases, you must use SQL commands (CREATE TABLE AS and INSERTION), or you must make sure that your columns have a specified precision.

    SQL * the VALUE LONGER variable limits the length of the LONG column you are copying. If all LONG columns contain data exceeds the value of LONG, COPY truncates the data.

    SQL * Plus performs a validation at the end of each successful COPY. If you set the SQL * variable more COPYCOMMIT DEFINED to a value positive n, SQL * Plus performs a validation after copying all lots n of records. The SQL * Plus ARRAYSIZE variable SET determines the size of a batch.

    Some operating environments require that the service names be placed between double quotes.

    From a SQL * Plus term on DB3, can resemble the command to move all content from my_table in DB1 to the same table in DB2

    COPY from user1/pass1@DB1 to user2/pass2@DB2 -
    INSERT INTO my_table -
    USING select * from my_table
    

    Note the SQL code * more line-continuation character ' - '. It is used to escape the newline character in a SQL * Plus command if you do not have to type all on one line. I use it all the time with this command, but I can't locate the documentation on that right now. Maybe someone else can put their finger on it.

    There are other ways to accomplish what the command copy and it is not without its quirks and limitations, but I find that there is usefulness in an Oracle Toolbox.

  • ORA-22992: cannot use LOB Locators selected from the remote tables...

    Oracle 10.2.1.0.4
    Solaris 10

    We try to access a table in another database via a db_link.

    The table we are trying to access has a LOB.

    We get the following error: ora-22992: cannot use LOB Locators selected from the remote tables.

    Is there a way to get around this? We need the data in the BLOB field.

    Thank you.

    See on metalink:

    ORA-22992 has a workaround solution in 10 gr 2
    DOC - ID: 436707.1

    Werner

  • cloumn on the emp table online

    Hello world

    I want to do EMP table in columns by departments
    under the name of employees of each Department

    for example,.

    10. 20
    CLARK | SMITH
    KING | FORD
    MILLER | ADAMS

    Thank you

    You mean like this?

    SQL> select * from emp;
    
         EMPNO ENAME      JOB              MGR HIREDATE                    SAL       COMM     DEPTNO
    ---------- ---------- --------- ---------- -------------------- ---------- ---------- ----------
          7369 SMITH      CLERK           7902 17-DEC-1980 00:00:00        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-1981 00:00:00       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-1981 00:00:00       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-1981 00:00:00       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-1981 00:00:00       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-1981 00:00:00       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-1981 00:00:00       2450                    10
          7788 SCOTT      ANALYST         7566 19-APR-1987 00:00:00       3000                    20
          7839 KING       PRESIDENT            17-NOV-1981 00:00:00       5000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-1981 00:00:00       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-1987 00:00:00       1100                    20
          7900 JAMES      CLERK           7698 03-DEC-1981 00:00:00        950                    30
          7902 FORD       ANALYST         7566 03-DEC-1981 00:00:00       3000                    20
          7934 MILLER     CLERK           7782 23-JAN-1982 00:00:00       1300                    10
    
    14 rows selected.
    
    SQL> ed
    Wrote file afiedt.buf
    
      1  with d1 as (select ename, row_number() over (order by empno) as rn from emp where deptno = 10)
      2      ,d2 as (select ename, row_number() over (order by empno) as rn from emp where deptno = 20)
      3      ,d3 as (select ename, row_number() over (order by empno) as rn from emp where deptno = 30)
      4  --
      5  select d1.ename as dept10, d2.ename as dept20, d3.ename as dept30
      6  from   d1 full outer join d2 on (d2.rn = d1.rn)
      7*           full outer join d3 on (d3.rn = nvl(d2.rn,d1.rn))
    SQL> /
    
    DEPT10     DEPT20     DEPT30
    ---------- ---------- ----------
    CLARK      SMITH      ALLEN
    KING       JONES      WARD
    MILLER     SCOTT      MARTIN
               ADAMS      BLAKE
               FORD       TURNER
                          JAMES
    
    6 rows selected.
    

    As already mentioned, in a reporting tool is much better.

  • SELECT on the emp table query

    Hello


    How to find the display the o/p as a manager name under employees dependent child parent like relation ship on the noraml emp table:

    sample o/p:

    use of name
    Nativity scene XX
    sales of yy
    YY1 sales
    Manager of the AA
    marketing of RR
    RR1 marketing


    Thank you

    921306 wrote:

    So I need, like that, child-parent relationship between the Manager under employees...

    Then join the parent with the child entity entity to create the parent-child relationship.

    The two entities are in the same table, it means to join the table to itself. For example

    SQL> select
      2          child.ename                     as CHILD,
      3          child.job                       as CHILD_JOB,
      4          nvl(parent.ename,'')      as PARENT,
      5          parent.job                      as PARENT_JOB
      6  from emp parent,
      7       emp child
      8  where child.mgr = parent.empno (+)
      9  /
    
    CHILD      CHILD_JOB PARENT     PARENT_JO
    ---------- --------- ---------- ---------
    FORD       ANALYST   JONES      MANAGER
    SCOTT      ANALYST   JONES      MANAGER
    JAMES      CLERK     BLAKE      MANAGER
    TURNER     SALESMAN  BLAKE      MANAGER
    MARTIN     SALESMAN  BLAKE      MANAGER
    WARD       SALESMAN  BLAKE      MANAGER
    ALLEN      SALESMAN  BLAKE      MANAGER
    MILLER     CLERK     CLARK      MANAGER
    ADAMS      CLERK     SCOTT      ANALYST
    CLARK      MANAGER   KING       PRESIDENT
    BLAKE      MANAGER   KING       PRESIDENT
    JONES      MANAGER   KING       PRESIDENT
    SMITH      CLERK     FORD       ANALYST
    KING       PRESIDENT 
    
    14 rows selected.
    
    SQL> 
    

    The basic concept is easy - set the parent entity, set the child entity, join the parent to the child.

    If some entities will not have parents (root entities), then an outer join is required of the child entity to the parent entity.

    Everything simply because the two entities are in the same table, does not change the logic or the approach. It's perfectly valid for a join table.

  • Selection of data after the extraction of metadata from the metadata table

    Hi, I have a metadata table where I store the name of the table, the names of the columns to select, start position and the end position.

    Start_Pos End_Pos Table_Name column_name
    1 10 ename emp
    11 20 empno, emp

    So I have to retrieve the records corresponding to the SQL:

    Rpad SELECT (ename, 10,' ') | RPAD (empno, 10,' ') FROM emp;

    The output of SQL created from the table of metadata should be written to a file with UTL_FILE

    I think he wanted more than just the use of UTL_FILE. Thus,.

    create or replace procedure write_data
            (p_table_name in varchar2) is
     v_file utl_file.file_type;
     v_sql varchar2(2000);
     v_line varchar2(2000);
     v_LEN number;
     TYPE refcurtyp IS REF CURSOR;
     cv refcurtyp;
    
    begin
      for C1 in (select * from Metadata_TabLE
                  where table_name = P_TABLE_NAME order by table_name) LOOP
         v_len := C1.end_pos - C1.start_pos +1 ;
         v_sql := v_sql ||'rpad('||C1.column_name ||', '|| v_len||', '' '' )||' ;
      end loop;
      v_sql := 'select '||substr(v_sql,1, length(v_sql)-2) || ' from '||p_table_name ;
      v_file := utl_file.fopen('YOURDIR', 'myfile.txt','W');
      open cv for v_sql ;
      loop
         fetch cv into v_line ;
              exit when cv%notfound;
            utl_file.put_line(v_file, v_line);
      end loop;
      utl_file.fclose(v_file);
    end;
    /
    
  • Remove the entry from the ARP table

    I need to create a program to remove an entry in the ARP table in Windows 7 with LabVIEW and TestStand.  The test that I develop contacts ESA via Ethernet.  Each HAD has the same IP address at the beginning but different MAC addresses.  I note that there may be long delays in test is running when you try to connect and remove the previous entry in the ARP table seems to help.  But now I have to do it manually through the command line.  The command 'arp d' requires elevated privileges.  I had a hard time getting LabVIEW to raise the system exec.  Does anyone have an ideas? Is there a .NET access to the ARP table?

    Thank you

    Paul

    I'll try to look into ARP sync settings setting in Windows.

    We have suffered from various problems of connection-performance TCP a few years ago and our solution was to change the default number of TCP sockets and delays (we knew port exhaustion). The tweeks eliminated most of our problems, no changes to code LV/TS not required.

    I tried to find info on ARP parameters for Windows 7, but it seems that there is much less info available that ther is for XP.

    Key words of the most common registry for older versions of Windows have been 'ArpCacheLife' and 'ArpCacheMinReferencedLife.

    EDIT:

    These parameters were apparently kidnapped in Vista. I found this on the site of $ M; they can apply to later versions, as well as M$ is a request for change to the management of the ARP...

    http://support.Microsoft.com/kb/949589

  • Using data from the control table

    Hello

    I would like to use the data entered in a table to automate volume/sequence of airflow for a test Chamber. As shown in the screenshot of control table, the first column indicates the number of iterations by elements of array in a series of tests and the second data column specifies the length of each line sequence. Entries in the other columns are specific to different valves and specify values set required in the flow meter.

    I guess my question is how can I index/assign each column of the table such that the data to exploit the respective valves are obtained in subsequent iterations all acquire simultaneously with data from other components in the order? While I recognize that the solution may be very simple, I searched on through various examples and messages on the tables and the tables without knocking on a solution. The attached .vi allows me to be a part of the series of tests.

    Best regards

    Callisto

    Hi Callisto,

    If I understand your question then the solution is actually quite simple. The important point to keep in min is the fact that the Table control can actually be treated as an array of string. You can then use all the traditional table manipulation tools and techniques to manipulate your data as you wish. For example, use the Array Index function to retrieve specific columns and then if you want to spend the individual elements in a column in a loop, wire the table until the loop and ensure that indexing is enabled. If you then want to use these data elements to control your test application, you can convert a portion of the resulting string in more useful to digital.

    All these concepts are illustrated in the attached VI. I hope this helps, but let me know if you have any other questions.

    Best regards

    Christian Hartshorne

    NIUK

  • Compare the records from the same table

    Hi all

    I have this sample, the data were rendered are group by my_id, the same number of records exist for the two my_ids (2 and 62) as:

    create table myTest as
    (
    my_id number, 
    fieldA varchar2, 
    fieldB number, 
    fieldC number, 
    cost_A number, 
    cost_B number
    )
    
    insert into myTest (my_id, fieldA, fieldB, fieldC, cost_A, cost_B)
    values (2, 'MAINT', 60, 5, 10.3, 15.00);
    insert into myTest (my_id, fieldA, fieldB, fieldC, cost_A, cost_B)
    values (2, 'MAINT', 70, 6, 20.3, 25.00);
    insert into myTest (my_id, fieldA, fieldB, fieldC, cost_A, cost_B)
    values (2, 'MAINT', 80, 7, 30.3, 35.00);
    insert into myTest (my_id, fieldA, fieldB, fieldC, cost_A, cost_B)
    values (62, 'MAINT', 60, 5, 10.3, 5.00);
    insert into myTest (my_id, fieldA, fieldB, fieldC, cost_A, cost_B)
    values (62, 'MAINT', 70, 6, 20.3, 25.00);
    insert into myTest (my_id, fieldA, fieldB, fieldC, cost_A, cost_B)
    values (62, 'MAINT', 80, 7, 10.3, 15.00);
    

    How can display the records with numbers of different costs for the same unique key (fieldA, fieldB and FieldC)?

    With the help of Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0.

    I hope that my message is clear.

    Thank you!

    Hello

    user9542267 wrote:

    ... I need all the exits...

    Me too.  Always show the complete, accurate, results you want from the data provided.  If you want 2 rows at the exit point, don't tell you want 1.

    Here are the results you want?

    MY_ID FIELDA, FIELDB, FIELDC OLD_COST_A COST_A OLD_COST_B COST_B

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

    MAINT 62 60 5 10.3 10.3 15 5

    MAINT 62 80 7 30.3 10.3 35 15

    If so, here's a way to get them:

    WITH got_old_costs AS

    (

    SELECT fielda, fieldb, fieldc, cost_a, my_id, cost_b

    , LAG (cost_a) OVER (PARTITION BY fielda, fieldb, fieldc)

    ORDER BY my_id

    ) AS old_cost_a

    , LAG (cost_b) OVER (PARTITION BY fielda, fieldb, fieldc)

    ORDER BY my_id

    ) AS old_cost_b

    OF mytest

    WHERE my_id IN (2, 62)

    )

    SELECT my_id, fielda, fieldb, fieldc

    old_cost_a, cost_a

    old_cost_b, cost_b

    OF got_old_costs

    WHERE my_id = 62

    AND (cost_a <> old_cost_a)

    OR cost_b <> old_cost_b

    )

    ORDER BY fielda, fieldb, fieldc

    ;

  • 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

  • Look at the calendar entry does not synchronize

    Watch ver 2.1 (S 13, 661), watch OS 2.1: when you enter the entrance of the calendar, with Siri, the watch does not synchronize with the Iphone 5 s worm 9.2 (13 c, 75). IOS 9.2.1.

  • Error 1 with STM write metadata on PSC-2200

    I have a request that I wrote for a PSC-2200 target which requires TCP communication. I chose the STM because it seems easy to work with and it worked fine up until now when I moved tests on windows-based computers using the real target. Now, my appl

  • This computer is not running windows genuine, even if his OEM installed OS and I recently changed my dying HDD

    I've recently updated my old WD Scorpio Blue HDD(640GB) format tip of Hitachi 1 TB 7200 RPM HARD drive. When I entered the serial number at the back of the laptop, it has not be activated and so I opted for the path of phone activation. (this was hap

  • Smartphones blackBerry in the registry problem

    My Blackberry Desktop 6.0 would open only a white screen.  I was told to uninstall and reinstall.  I did it a couple of times, not good.  I am now, as shown here contain for a clean uninstall: http://bbry.lv/crtVBZ and I am doing everything as admini

  • OfficeJet J4580 upgrade to windows 7

    Currently have Officejet J4580 (not made for Windows 7) connected to a desktop computer with Windows XP.  Bought a laptop with Windows 7, I also want to add the Officejet so that both computers print to the Officejet.  Is this possible?