Go add column in my inside, select

Hi all

I tried to put my script using the table emp and need your help to get my task done:

My query is below:

SELECT EmpNo, ename,

(SELECT deptno

OF the emp A

WHERE A.empno = emp.empno)

EMP;

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

Now, I want to add another column with my inside, select something like below:

Query

SELECT EmpNo, ename,

(SELECT deptno, hiredate

OF the emp A

WHERE A.empno = emp.empno)

WCP

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

I added hiredate inside select but I get the error below:

Error

ORA-00913: too many values

00913 00000 - "too many values.

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

My question is that how will I integrate new column in my inside, select without using select distinct internal. Really appreciate your advice. Thank you

Concerning

Line


979596 wrote:

Amazing and thank you for your query, will check in detail and let you know, but the thing is that how did you that?  I wonder if you can explain your query more then I really appreciate it.

First, we must get our condition and set the line number with order by e.manu_date for each e_id read ROW_NUMBER:

As we have for where e.p_nm in ('BUMPS', 'ESP') our query should return 2 records for each e.id, and we numering it

SELECT e.*,

ROW_NUMBER() over (partition by order by e.manu_date e_id) r

Of e e_package

where e.p_nm in ('BUMPS', 'ESP')


E_ID P_ID P_NM MANU_DATE R
100 1 ESP 01.01.2013 1
100 2 BUMPS 01.02.2013 2
200 5 ESP 01.01.2013 1
200 6 BUMPS 01.02.2013 2


After that we pivot data with function of pivot that works starts with the 11 g version with our number line and receive each p_id, p_nm, the manu_date


Select *.

from (SELECT e.*,

ROW_NUMBER() over (partition by order by e.manu_date e_id) r

Of e e_package

where e.p_nm in ('BUMPS', 'ESP')) q

Pivot (Max (P_ID) f_p_id, max (p_nm) f_p_nm, max (manu_date) f_manu_date for r in (1,2)

and results

Battle of reading

http://www.orafaq.com/wiki/pivot

Oracle Pivot examples

11g - pivot.html

----

Ramin Hashimzade

Tags: Database

Similar Questions

  • How to add column after select *, ABC

    Dear friends,

    I create report with SQL query
    select * from CRM_ISSUE_PROBLEM IP where IS_ACTIVE ='Y'
    I want to add BILLNO column below after Select * look like select *, nvl ((select count (case_id) of CRM_ISSUE_PROBLEM_DETAIL AD
    (where IP.case_id = AD.case_id GROUP BY case_id), 0) AS BILLNO
    CRM_ISSUE_PROBLEM IP where IS_ACTIVE = 'Y '.

    nvl((select count(case_id) from CRM_ISSUE_PROBLEM_DETAIL AD 
    where IP.case_id=AD.case_id GROUP BY case_id),0) AS BILLNO 
    How to add column with using Select * SQL query.


    How can I do this?

    Thank you

    Hello

    select IP.*, new_column
    ....
    from TABLE IP
    
  • Invalid procedure after alter table add < column >

    Hello Experts,

    I was faced with a situation where I add a column in a table that is used in a procedure, immediately after the addition of the new procedure associated with this table column becomes invalid.

    Can someone explain please know why this happens.

    Database version:-11.2.0.4.

    I was faced with a situation where I add a column in a table that is used in a procedure, immediately after the addition of the new procedure associated with this table column becomes invalid.

    Can someone explain please know why this happens.

    Yes - the Oracle documentation explains this. I found this doc with a simple search of "column, add the oracle 11g invalid procedure.

    http://docs.Oracle.com/CD/B28359_01/server.111/b28318/dependencies.htm#CHDJIIFC

    Table 6-2 , shows how objects are affected by changes to other objects upon which they depend.

    Table 6-2 operations affects this object status

    Operation Where the status of dependent objects

    ALTERTABLEtableADDcolumn

    INVALIDWhen:

    • Uses of the object (except a view)-dependent SELECT * on table .
    • Dependent object uses table %rowtype .
    • Dependent object performs INSERT on table without specifying a list of columns.
    • Dependent object references table in the query that contains a join in SQL.
    • Dependent object references table in the query that refers to a PL/SQL variable.

    Otherwise, no change.

    Read the WHOLE ARTICLE and see if it does not have to explain your problem.

  • Add column according to date

    Hello

    I want to add column as from Time_period conditon below

    If the review date is between the date of yesterday for a week, then it should display as "week1.

    If the review date is 2nd week, then it should display as "semaine2" and so on.

    I tried, but do not get the correct result.

    Can someone help me.

    Thank you

    with abc as

    (select 101 as id, to_date('21-JUL-2015','DD-MON-YYYY') as double union review

    Select 102, double union to_date('17-JUL-2015','DD-MON-YYYY')

    Select 103, to_date('13-JUL-2015','DD-MON-YYYY') of double union

    Select 104, to_date('12-JUL-2015','DD-MON-YYYY') of double union

    Select 105, double union to_date('01-JUL-2015','DD-MON-YYYY')

    Select 106, to_date('01-JUN-2015','DD-MON-YYYY') of double union

    Select 107, to_date('29-JUN-2015','DD-MON-YYYY') of double union

    Select 108, to_date('07-JUL-2015','DD-MON-YYYY') of double union

    Select 108, double to_date('03-JUL-2015','DD-MON-YYYY')

    )

    SELECT id,

    -case when trunc (review) between trunc (sysdate)-1 and trunc (sysdate)-7 then "week1.

    When trunc (review) between trunc (sysdate)-8 and trunc (sysdate)-15 then 'semaine2 '.

    When trunc (review) between trunc (sysdate)-16 and trunc (sysdate)-23 then "week3.

    Another 'other '.

    end as Time_period

    ABC

    Hello

    You must provide the lower date first in your between the declaration

    -case when trunc (review) between trunc (sysdate)-7 and trunc (sysdate)-1 then "week1.

    When trunc (review) between trunc (sysdate)-15 and trunc (sysdate)-8 then 'semaine2 '.

    When trunc (review) between trunc (sysdate)-23 and trunc (sysdate)-16 then 'week3.

    Concerning

    Marcus

  • Add column if the value in another column

    How can I add a column as column name 'YES_OR_NO.

    SELECT VALUE_ID IN THE TABLE TABLE_NAME

    VALUE_ID
    ---
    1
    2
    3
    4
    5

    Now, I want to create another column in the sql query called YES_OR_NO and that if there is a value in VALUE_ID then column YES_OR_NO must say 'YES' if there is no value in the column VALUE_ID of this line YES_OR_NO must say 'NO '.

    or just a way for her also to work would be to show this new column or not if a value in another column of table_name_2 (this would be ideal)
    If new column yes_or_no and fill by a Yes or a no if a value is found in another table

    Assuming that you are on a version that supports the CASE expression:

    SELECT VALUE_ID
          , case when VALUE_ID is null then 'NO' else 'YES' end as YES_NO
    FROM TABLE_NAME
    
  • Some songs bought on Itunes and add them to an existing selection. They appear in the playlist and on computer but will not be synchronized to the Iphone. Help, please!

    Bought a few songs on ITunes and add them to an existing selection. They appear on the computer and in the playlist, but will not be synced to an existing selection on the IPhone 6. Help, please.

    This is the computer on which the phone is synchronized, and playlist is selected on the tab music from the phone to synchronize the phone? If the 'sync' button is not a copy the playlist update on you have tried to make a change on the screen of synchronization (for example in selecting/disable-selecting a playlist and sync and then get back on your original selection and re-sync)?

  • I downloaded the Sync Firefox Add on, but when I select 'Add a device' it are launching a help page which tells me to click on 'Add a device' - circle without end!

    I downloaded the Sync Firefox Add on, but when I select 'Add a device' it are launching a help page which tells me to click on 'Add a device' which is a circle without end!

    Any advice appreciated

    Sorry about that. Using pages have been updated for the new 'add a device' addresses in Firefox 4, but the add-on for Firefox 3.6 is still using an older, different process.

    You can download Firefox 4 release candidate here and use the new "easy installation" process described in the help pages: http://firefox.com/rc

    Or if you prefer to stay with Firefox 3.6, so instead of clicking 'Add a device' on your computer, press the 'Connect' button on your phone or other device, and then click "I'm not near my computer...". "and enter your email address and password sync key. (If you do not know your key synchronization, see synchronize your bookmarks from Firefox, history, passwords, etc.)

  • Is it possible to add columns to explore details view customization

    Under XP it is possible to add columns for Windows Explorer details columns that are not the default choice?  I want to add a column "written by" and "reviewed by" and preferably have the name of the preparer (or reviewers) or initials and a date stamp

    Hello

    I suggest you to post your query in development issues General Windows Desktop for better eon helps the concern: http://social.msdn.microsoft.com/Forums/en-US/windowsgeneraldevelopmentissues/threads

  • ALTER TABLE hf_altertest ADD COLUMN does not

    I am using ORACLE 11g and my FDI is Developer SQL 4.1.1

    It's all free PC version that has limits.

    I tried on:

    CREATE TABLE hf_altertest

    (

    contact_id INTEGER NOT NULL

    , name VARCHAR (25)

    , last_name VARCHAR (35)

    PRIMARY KEY (contact_id)

    );

    ALTER TABLE hf_altertest State to add a CHAR (2) COLUMN;

    But when I go to run the ALTER TABLE statement then I get following error:

    rror starting at line: 1 323 in command.

    ALTER TABLE hf_altertest State to add a CHAR (2) COLUMN

    Error report-

    SQL error: ORA-00904: invalid identifier

    00904, 00000 - '% s: invalid identifier '.

    * Cause:

    * Action:

    I can run the same code in MySQL without error.

    This leads me to think that maybe I'm just bumping into a limit in the free version of PC.

    Any thoughts?

    3003916 wrote:

    I am using ORACLE 11g and my FDI is Developer SQL 4.1.1

    It's all free PC version that has limits.

    ALTER TABLE hf_altertest State to add a CHAR (2) COLUMN;

    But when I go to run the ALTER TABLE statement then I get following error:

    rror starting at line: 1 323 in command.

    ALTER TABLE hf_altertest State to add a CHAR (2) COLUMN

    Error report-

    SQL error: ORA-00904: invalid identifier

    00904, 00000 - '% s: invalid identifier '.

    * Cause:

    * Action:

    I can run the same code in MySQL without error.

    This leads me to think that maybe I'm just bumping into a limit in the free version of PC.

    Any thoughts?

    There is no LIMIT to the 'free' version  If you read the error message he said THAT was not a valid identifier.  Just to show you that I tried your erroneous statement

    ALTER TABLE hf_altertest ADD COLUMN state2 CHAR(2);
    

    and here is the indicator error message in SQL +.

    SQL * more: Production of liberation 12.1.0.2.0 Tue Oct 15 14:34:57 2015

    Copyright (c) 1982, 2014, Oracle.  All rights reserved.

    Connected to:

    Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0 - 64 bit Production

    With the partitioning, Real Application Clusters, Automatic Storage Management, OLAP

    and Data Mining options

    Add a COLUMN state2 TANK (2)

    *

    ERROR on line 2:

    ORA-00904: invalid identifier

    As you can see (and as the previous poster of response indicates), the 'COLUMN' KEYWORD is not necessary when adding new columns.  Only when 'RENAME' is used, then you add the keyword COLUMN.

    See the documentation for the syntax of ALTER TABLE here--> http://docs.oracle.com/database/121/SQLRF/statements_3001.htm#SQLRF01001

    See specific clause RENAME syntax here--> http://docs.oracle.com/database/121/SQLRF/statements_3001.htm#i2183480

  • Can I use * and the list of the column names in a select query

    PLSQL again.  Can I use * and the list of the column names in a select query, i.e. Select *, col1, col2 from Mytable.  When I do that my questions tend to the bomb.  Can do in other databases.

    Thank you

    Mike

    Hi, Mike,.

    If there is something else in the more SELECT clause *, then * must be qualified with a table name or alias.

    For example:

    SELECT Mytable. *, col1, col2

    FROM MyTable;

  • Add a mask on all selected layers.

    Hello guys! I'm here looking for a script that adds the mask on all selected layers.

    Pictures.png

    Sorry, I found that I had made a change of course, it should work now.

    #target photoshop;
    app.bringToFront();
    
    if(documents.length) main();
    function main(){
    var selectedlayers = getSelectedLayersIdx();
    selectedlayers.reverse();
    for(var z in selectedlayers){
        selectLayerByIndex(selectedlayers[z]);
        selectLayerData();
         createMask();
        }
    app.activeDocument.selection.deselect();
    for(var a in selectedlayers) {selectLayerByIndex(selectedlayers[a],true);}
    };
    function getSelectedLayersIdx(){
          var selectedLayers = new Array;
          var ref = new ActionReference();
          ref.putProperty(charIDToTypeID('Prpr'), stringIDToTypeID('targetLayers'));
          ref.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
          var desc = executeActionGet(ref);
          if( desc.hasKey( stringIDToTypeID( 'targetLayers' ) ) ){
             desc = desc.getList( stringIDToTypeID( 'targetLayers' ));
              var c = desc.count;
              var selectedLayers = new Array();
              for(var i=0;i		   
  • mixture of column type in the select statement

    Oracle 11g r2.

    tab_test (name varchar2, blob... photo)

    (1) select general use *.

    Stored procedure: open ref_cursor to some * of table_test...

    Coast of java: call.registerOutParameter (1, OracleTypes.CURSOR);  Call.Execute ();

    It works very well.

    (2) enter the name of the column in the select such as

    Stored procedure: open ref_cursor to select name, photo table_test...

    Coast of java: call.registerOutParameter (1, OracleTypes.CURSOR);  Call.Execute ();

    ERROR: java.sql.SQLSyntaxErrorException: ORA-00932: inconsistent data types: expected - got BLOB

    My question, if I specify the column names in the select statement, including the varchar2 and blob, how can I registerOutParameter (1, OracleTypes.CURSOR);?

    Thank you

    Scott

    PS The number of returned columns, in real case schenario, is a little, so I prefer to specify column names.

    Wrong forum. This forum is for questions of sql and pl/sql.

    Enter the question ANSWER and the repost in the JDBC forum

    https://community.oracle.com/community/developer/english/java/database_connectivity/java_database_connectivity _(jdbc)

    When repost you provide the necessary information to help you:

    1. information on the full version for Oracle DB

    2 version of the JDK

    3. the name and version of the JDBC jar file

    4. real code that demonstrates the problem

    You should also review the info re REF CURSOR in the JDBC Developer's Guide

    http://docs.Oracle.com/CD/E16655_01/Java.121/e17657/oraint.htm#i1058743

  • How to use the transformation script to add columns to the PK?

    I'm working on a script transformation that:
    -create a table
    -Adds the columns to the table
    -create a primary key for the table

    See the below script.
    Now, I want to add the primary key column.
    Documentation fix r: class IndexColumnUsage

    The Index of the class has a getter: getIndexColumnUsageList()
    and the list apply: applyIndexColumnUsageList

    Someone at - it an idea how to use these methods to add the column to the PK?

    I thank in advance.


    relational = model.getDesign () .getFirstOpenRelationalDesign ();
    table = relational.getTableSet () .createTable (null);
    table.setName ("TABLE");
    column = table.createColumn (null);
    column.setName ("COLUMN");
    index = table.createIndex (null);
    index.setName ("PK");
    index.setIndexState ("primary obligation");

    Hello

    If you have the column and index (both belonging to the same table) use:

    the index. Add (Column);

    to remove the column:

    the index. Remove (Column)

    Philippe

  • Add columns

    Hi all

    11g.2 Oracle under OL 5.6

    I must add column in my paintings like the below:
    desc x ;
    id 
    name 
    sal 
    
    i want to add column comm 
    
    desc x;
    id 
    comm
    name
    sal
    in fact we have tables that hold the CDRs, but today I found the CDRs not uploaded in the database because of the team IN to increase the columns in the table
    We have a 40 column but it became 41 and the added column life team in position 32.
    so I need to know how to do to add the column in the middle of my table without re-creating the table again (contain data).


    Thank you

    I don't think there is any direct sql command to do so. But you can do something for this. This link will help you:

    http://www.orafaq.com/FAQ/how_does_one_add_a_column_to_the_middle_of_a_table

  • Add columns to a table

    Hi all
    I have a form that I can add up to 6 columns.
    I created dynamic columns in the table. When I click Add columns until she reach 2, it will automatically add a new table and location number will be added 2. But it is does not work.

    I spent 3 days working on it, but it does not work.
    Pleas help.

    Here is my code:

    Form1.screen17.table3b.BehaviousButtons.AddColumn::click - (JavaScript, client)
    var form1.screen17.table3b.Table3.HeaderRow._SCOL2.count = nCount;

    If (nCount > 0 & & nCount < 3) {}
    Form1.screen17.table3b.table3.HeaderRow._SCOL2.addInstance (1);
    Form1.screen17.table3b.table3.Row1._SCOL2.addInstance (1);
    Form1.screen17.table3b.table3.row2._SCOL2.addInstance (1);
    Form1.screen17.table3b.table3.Row3._SCOL2.addInstance (1);
    Form1.screen17.table3b.table3.Row4._SCOL2.addInstance (1);
    Form1.screen17.table3b.table3.Row5._SCOL2.addInstance (1);
    Form1.screen17.table3b.table3.Row6._SCOL2.addInstance (1);
    Form1.screen17.table3b.table3.Row7._SCOL2.addInstance (1);
    Form1.screen17.table3b.table3.Row8._SCOL2.addInstance (1);

    }
    ElseIf (nCount > = 3) {}
    Form1.screen17.table3b._Table3.addInstance (1);

    }

    Check out post of John Brinkman here: http://blogs.adobe.com/formfeed/2011/10/tables-with-variable-numbers-of-columns.html.

Maybe you are looking for