What can be the SQL query for this requirement?

Hello
I have a table with the fields like this:

ID DESC PARENT
01 02 ABC
02 01 ABC1
03 01 ABC2
04 02 ABC4


In the table above column PARENT refers to the column ID, but actually in the SQL query, I want to have ID DESC and PARENTDESC (i.e., desc ID value corresponding)

Output real I need is

SELECT ID, DESC? from table where ID = someValue. Now, if I provided ID = 01 then output should be like this:

ID DESC PARDESC
ABC1 ABC 01


Can anyone help on what may be the required sql query?

Published by: bootstrap on April 29, 2011 06:15

SELECT T1.ID, T1. DESC, T2. / / DESC
FROM TABLEA T1, T2 TABLEA
WHERE T1.ID = '01'
AND T2.ID = T1. PARENT;

Tags: Database

Similar Questions

  • How can I write the SQL query for this requirement?

    Hello

    I have a table that looks like this:

    NAME | ANNUAL |     VALUE
    ==== | ====== | =====
    execno |     480.     000004
    step |      480.     0400
    SCNA |     480. cd_demo
    System |     480.     D47-010
    type |     480.     step
    free_text |     480.     stage 400
    rbare |     480.     RBA-1
    execno |     482. 000004
    SCNA |     482. cd_demo
    System |     482.     D47-010
    free_text |     482.     step 300
    step |          482.          0300
    type |      482.     step
    rbare |     482.     RBA-1
    execno |     483.     000001
    type |     483.     step
    rbare |     483.     rke1
    SCNA |     483.     rke10
    step |     483.     0240

    Now, say that I want to fetch ONLY annual with execno = '000004' and '400' = step and scna = "cd_demo" and system = "d47-010' and type = 'step', how to write SQL code?
    At first, it seemed like a simple writing query but I've been struggling with it for hours without success. I must admit though that I'm not strong in SQL :-)
    There, can anyone help? Please...

    Thanks in advance.

    Emmanuel

    Published by: user12138559 on October 30, 2009 03:05

    Hi, Emmanuel.

    Welcome to the forum!

    Here's a way to do what you asked:

    SELECT       doc_id
    FROM       table_x
    GROUP BY  doc_id
    HAVING       SUM (CASE WHEN name = 'execno' AND value = '000004'  THEN 1 END) > 0
    AND       SUM (CASE WHEN name = 'step'   AND value = '400'     THEN 1 END) > 0
    AND       SUM (CASE WHEN name = 'scna'   AND value = 'cd_demo' THEN 1 END) > 0
    AND       SUM (CASE WHEN name = 'system' AND value = 'd47-010' THEN 1 END) > 0
    AND       SUM (CASE WHEN name = 'type'   AND value = 'step'    THEN 1 END) > 0
    ;
    

    If you think that a WHERE clause would be used, but WHERE does apply to a single line. You need a condition that checks several rows in the same group.
    WHEN has an effect something like WHERE.

    Published by: Frank Kulash, October 30, 2009 06:26

    This solution assumes that (name, annual) is unique.

  • How to make the simple query for this scenario... ?

    Hello:

    Dummy table provided for simplicity.

    It's my database table (Table_A)

    Date1 | Plane1 | Category | Duration | Fees
    01/01/2011 | A | Gold | 5. 2
    01/01/2011 | C | Money | 4. 11
    01/01/2011 | B | Gold | 6. 2
    01/01/2011 | D | Gold | 2. 4
    01/01/2011 | B | Gold | 3. 5
    01/01/2011 | A | Money | 4. 8
    01/01/2011 | B | Gold | 1. 3

    I need to write a query to get the result below:

    Date1 | Plane1 | Sum_Duration | Sum_Charge | Sum_Gold_Duration | Sum_Gold_Charge | Sum_Silver_Duration | Sum_Silver_Charge
    01/01/2011 | A | 9. 10. 5. 2. 4. 8
    01/01/2011 | B | 10. 10. 10. 10. 0 | 0
    01/01/2011 | C | 4. 11. 0 | 0 | 4. 11
    01/01/2011 | D | 2. 4. 2. 4. 0 | 0

    This query will provide the 1st four columns:

    SELECT Date1,
    base1,
    Sum (Duration) Sum_Duration,
    Sum (load) Sum_Charge
    FROM TABLE_A
    GROUP BY date1, rarateplan

    But I need to know how to get the rest of the columns (i.e. Summary according to categories; from 5 to 8 columns)? Is this can be done in a single query without writing subqueries?

    Please let me know, (with code), the best way.

    Thank you-
    Tanvir

    Use like this:

    SELECT Date1,
    base1,
    Sum (Duration) Sum_Duration,
    Sum (load) Sum_Charge,
    SUM (decode(Category,'Gold',duration,0)) Sum_Gold_Duration,
    SUM (decode(Category,'Gold',charge,0)) Sum_Gold_charge,
    SUM (decode(Category,'Silver',duration,0)) Sum_Silver_Duration,
    SUM (decode(Category,'Silver',charge,0)) Sum_Silver_charge
    FROM TABLE_A
    GROUP BY date1, rarateplan

    Published by: SANT007 on August 11, 2011 11:04

  • If an entry is a constant range, is a tool that can make the exit choose for this number

    I don't really know if it has a name, but I want to capture a constant between 0 and 7. I wish there will be 8 outputs, and according to the value of the entry, the corresponding output is selected. The output could be 1.0 or T/F. I think I could achieve the same goal with a lot of programming, but I was wondering if it was already a tool.  Thank you.

    Index table will do what you want.  Just all your outings possible in an array and index on any element you want.

  • What is the best solution for this idea...

    I have a task I'm trying to test and understand what would be the best solution for this, any recommendations would be appreciated.

    Devices at your fingertips:

    -2 ESXi hosts

    -1 iSCSI SAN OpenFiler (new just installed the app)

    2 ESXi hosts run a small amount of virtual machines that are all in the same domain.  I want to have a file server (or a repository somewhere) that houses a folder with easily accessible software (OS, Office, etc.) on the field.

    According to me, that if I made a virtual machine with a large hard drive and share the software, this would not be the best way because it would be dependent on the OS.  Someone has talked about doing a separte VMDK for it and then install it on the operating system on the virtual machine. This way I could always remove the and mount it somewhere else.

    It seems a bit weird to me that the software within this "shared folder" will also be sitting on the data store (if I create a virtual machine and need to use the OS/etc).  Not that doubles the space for the same software (in the comments, then the data store)?

    What is the best approach to make this action which can be accessed at the prompt (mostly windows) in the field?

    What is the best way to stay away the software doubles in action and on the data store?

    Please forgive me if I put interpereted your question.

    The problem you seem to face is that you must mount the ISOs of VMS software and physical systems that are on the field.

    (please, correct me if I'm wrong on this)

    If this is the case, then the best way to do would be to create sharing NFS on the openfiler, if you use openfiler to main databases also then he would be better for sharing this was separated to prevent the other help to be able to tamper with the VMDK and VMX files for your virtual machines.

    This could then be mounted in ESX to access the ISOs. While being easy to install on Linux and Windows machines to access the ISOs.

    If you have questions about NFS mounting in windows, so, this link may help

    http://sagehacks.WordPress.com/2009/01/21/HOWTO-mount-NFS-shares-under-Windows-7

    If you are needing to access the VMs software and it is mainly the downloading ISOs then th ISO directly to the data store is possible.

    This allows you to use ESX to mount the ISO on the virtual machine.

    On the point that the software will use double disk space when you install the software on a machine virtual car will be on the network share and the VMDK virtual machines in the data store. That's right, and that's by design.

    Each virtual machine under ESXI is 'independent' (http://www.vmware.com/virtualization/virtual-machine.html)

    This means that each virtual computer must have its own copy of the application.

    This perspective reflection of each virtual machine as a separate system of 'physical '. They interact with each other as if they were physical systems.

    Each VMDK resembles a physical hard disk. Being accessible (in most configurations) 1 VM at a time.

    So if you had a set of physical systems connected to a domain and I wanted to install an application on each one, then each would have its own local copy of the application. It's the same thing with virtual machines.

    However

    If you configure a set of physical machines so that you run the software from a network share. It is possible to do the same thing using virtual machines using the exactly the same configuration. However, the chiefs more associated to this are important in both cases.

    Concerning

    Cyclooctane

  • What use of the WWAN CARD for latitude E6440

    I have a latitude E6440
    What can use a mini-map for this laptop?

    Thank you

    Hi danduongpho,

    Thanks for the post! The Latitude E6440 is compatible with the broadband MOBILE of Dell 5570 card, have the drivers written by our engineers for this material:

    Compatibility: Card wireless Dell 5570 HSPA + (42mbps network) Mobile Broadband

    Systems
    • Latitude E6440
    Operating systems
    • MS Windows 7 32-bit
    • MS Windows 7 64 bit
    • MS Windows 8 32-bit
    • MS Windows 8 64-bit
    • MS Windows 8.1 32-bit
    • MS Windows 8.1 64-bit

    http://www.Dell.com/support/home/us/en/04/drivers/DriversDetails?driverId=YNYT0&FILEID=3397439438&osCode=W764&ProductCode=latitude-e6440-laptop&LanguageCode=en&CategoryID=cm

    Kind regards

  • I have adobe photoshop elements 9. I changed Windows 8.1 for windows 10. Now it doesn't work. When I trty to reinstall the software, windows will uninstall it. I habe no icon on the desktop to start the program. For this purpose I can't use it. What I hav

    I have adobe photoshop elements 9. I changed Windows 8.1 for windows 10. Now it doesn't work. When I trty to reinstall the software, windows will uninstall it. I habe no icon on the desktop to start the program. For this purpose I can't use it. What should I do? Thanks for your help. Wolf-Eberhard

    Check your installed programs and so PES 9 is listed, uninstall it by using uninstall.

    Then clean by http://www.adobe.com/support/contact/cscleanertool.html

    Restart your computer, and then reinstall pse 9.

  • I made a site with Muse and now the plugin youtube is blocked. What can be the reason for this?

    I made a site for my school with Muse. Now, I want to add some videos on the site. The youtube plugin will not work. It is said the plugin is blocked. What can be the reason?

    Hello

    Some associates of the son,

    Impossible to incorporate and view YouTube videos to Muse: 'plugin blocked. "

    plugin blocked to ship video youtube html?

    Let me know if you have any question.

  • SQL query for the region of the tree

    Hello

    I was wondering if someone is able to help me work on a SQL query, to format the data in the table required in a part of the tree... I've never used a tree and I'm fighting to get the right data (if possible).

    The data in the table looks like this:

    data.PNG

    I want to put it in a tree, using level 1 level6 with a final layout that would look like this:

    tree.PNG

    As you can see, the data are formatted in level6 down in the tree, but are filled in the table from level 1. Not all of the columns will be filled, so level2 for anyone 4 (France) is the equivalent of level in the tree like level6 to person 1 (Spain).

    This is Apex 4.2.5

    Oracle 11.2.0.3.0

    Sample data:

    CREATE TABLE employees
       ( employee VARCHAR2(100),
         level1 VARCHAR2(100),
         level2 VARCHAR2(100),
         level3 VARCHAR2(100),
         level4 VARCHAR2(100),
         level5 VARCHAR2(100),
         level6 VARCHAR2(100)   
       );
    
    INSERT INTO employees (employee, level1, level2, level3, level4, level5, level6) VALUES ('Person1','Team One','Recruitment','Human Resources','Fictituous Company','Murcia','Spain');
    INSERT INTO employees (employee, level1, level2, level3, level4, level5, level6) VALUES ('Person2','Team Four','Testing','IT','Big Corporate','Hanover','Germany');
    INSERT INTO employees (employee, level1, level2, level3, level4, level5, level6) VALUES ('Person3','Big Corporate','Hanover','Germany', null, null, null);
    INSERT INTO employees (employee, level1, level2, level3, level4, level5, level6) VALUES ('Person4','Brittany','France', null, null, null, null);
    INSERT INTO employees (employee, level1, level2, level3, level4, level5, level6) VALUES ('Person5','Team Three','Testing','IT','Big Corporate','Hanover','Germany');
    INSERT INTO employees (employee, level1, level2, level3, level4, level5, level6) VALUES ('Person6','Public Relations','Government Agency','Brittany','France', null, null);
    
    

    Added example given.

    Hello

    Apex-user wrote:

    Thanks Frank, this is a good example, I can work with that! Your assumptions are correct.

    A question I came, however, is that I have a data segment that comes across poorly formatted so to speak... where only the lower levels (1-2, etc.) have been filled from the bottom up.

    An example of this data would be:

    1. INSERT INTO employees (employee, level 1, 2, level3, level4, level5, level6) VALUES ('Person7', 'One Team', 'Test', null, null, null, null);

    As you can see that if you rerun the select, the test team is now duplicated, both at the level of the root in the tree as it should.

    You are not sure if the sql can be adjusted to account for this, or if it's too hard?

    It is obviously a question of data and I am trying to solve this separately (extracted data from another system out of my control).

    Thank you!

    Sorry, I'm confused.

    You say that my assumptions were correct.  What includes supported that "If test ' occurs under 'IT' in a row, then the extent of the 'Testing' occurs, it must be under"IT "?  Right after you say that assumptions are correct, you give an example where 'Testing' occurs under 'IT' to a single line, but it is not less 'IT' to another line and where is 'One Team' under 'Testing' in a line, but is 'One Team' under 'Recruitment' in another row.

    When a situation like this occurs, how you cope?  Whenever you have a problem, please post the exact results you want from the given sample data, and an explanation of how you get these results.  If you don't know about what would be the ideal results, or if you are flexible on the exact results, then at least give an example and explain your reasons.

    Maybe you want to change the got_parent of subquery like this:

    WITH unpivoted_data AS

    (

    SELECT *.

    Employees

    UNPIVOT (node_name

    FOR lvl (level1 AS 1

    level2 AS 2

    level3 AS 3

    level4 AS 4

    level5 AS 5

    level6 AS-6

    )

    )

    )

    got_parent AS

    (

    SELECT c.node_name

    MIN (p.node_name) AS a parent

    Of unpivoted_data c

    LEFT OUTER JOIN unpivoted_data p ON p.employee = c.employee

    AND p.lvl = c.lvl + 1

    GROUP BY c.node_name

    )

    SELECT LPAD (' ' ')

    2 * (LEVEL - 1)

    ) || Node_name AS entity

    OF got_parent

    START WITH parent IS NULL

    Parent = node_name PRIOR CONNECTION

    ;

    In this way, if 'Test' is current 'IT' in one line, but not under what in another line, whether under would consider the 'IT' request and not to be a root.  If 'One Team' sudden 'Testing' in a line, but under "Recruitment" in another line, it will be (arbitrarily) consider it under "recruitment".

  • Single SQL query for the analysis of the date of customs declaration under the table of Stock codes

    Dear all,


    Please tell us a single SQL query for the below,

    We have a Table of Stock as shown below,

    STOCK_TABLE

     

    ITEM_CODE

    (item code)

    BAT_NO

    (lot no.)

    TXN_CODE

    (transaction code)

    DOC_NO

    (number)

    BOE_DT

    (date of the customs declaration)

    I1

    B1

    I1

    I2

    I3

    B70

    I4

    B80

    I5

    B90

    T102

    1234

    JULY 2, 2015

    I6

    B100

    We have to find the date of customs declaration (i.e. the date when the items have come under this particular table) for items that are not attached to any document (that is, who have TXN_CODE, DOC_NO and BOE_DT fields with a NULL value).

    For each item in the table of actions, which is not attached to any document, the customs declaration date is calculated as follows.

    1. If (code section, lot number) combination is present under HISTORY_TABLE, the date of customs declaration will receive the UPDT_DT, the transaction code (TXN_CODE) is an IN or transactions (which can be analyzed from the TRANSACTIONS table).

    2. If (code section, lot number) combination is NOT currently at the HISTORY_TABLE (or) the transaction code respective to item - batch number combination code is an operation then customs declaration date will be the date of the document (DOC_DT) that we receive from one of the 3 tables IN_TABLE_HEAD that contains the element of that particular lot.

  • If the case 1 and case 2 fails, our customs declaration date will be the last date of document (DOC_DT) that we receive from one of the 3 tables IN_TABLE_HEAD containing that particular item and the BAT_NO in expected results will be that corresponding to this document, as appropriate, to another NULL.

  • If the case 1 or case 2 is successful, the value of the last field (in the output expected, shown further below) BATCH_YN will be 'Y', because it fits the lot. Otherwise it will be 'n'.
  • HISTORY_TABLE

     

    ITEM_CODE

    BAT_NO

    TXN_CODE

    DOC_NO

    UPDT_DT

    I1

    B1

    T1

    1234

    JANUARY 3, 2015

    I1

    B20

    T20

    4567

    MARCH 3, 2015

    I1

    B30

    T30

    7890

    FEBRUARY 5, 2015

    I2

    B40

    T20

    1234

    JANUARY 1, 2015

    TRANSACTION

     

    TXN_CODE

    TXN_TYPE

    T1

    IN

    T20

    OFF

    T30

    ALL THE

    T50

    IN

    T80

    IN

    T90

    IN

    T60

    ALL THE

    T70

    ALL THE

    T40

    ALL THE

    IN_TABLE_HEAD_1

     

    H1_SYS_ID

    (primary key)

    TXN_CODE

    DOC_NO

    DOC_DATE

    H1ID1

    T1

    1234

    JANUARY 1, 2015

    H1ID2

    T70

    1234

    FEBRUARY 1, 2015

    IN_TABLE_ITEM_1

     

    I1_SYS_ID

    H1_SYS_ID

    (foreign key referencing H1_SYS_ID in IN_TABLE_HEAD_1)

    ITEM_CODE

    I1ID1

    H1ID1

    I1

    I1ID2

    H1ID1

    I100

    I1ID3

    H1ID2

    I3

    IN_TABLE_BATCH_1

     

    B1_SYS_ID

    TXN_CODE                DOC_NO

    (now in IN_TABLE_HEAD_1)

    BAT_NO

    B1ID1

    T1

    1234

    B1 / can be empty

    B1ID2

    T70

    1234

    B70

    IN_TABLE_HEAD_2

     

    H2_SYS_ID

    (primary key)

    TXN_CODE

    DOC_NO

    DOC_DATE

    H2ID1

    T30

    4567

    FEBRUARY 3, 2015

    H2ID2

    T60

    1234

    JANUARY 3, 2015

    IN_TABLE_ITEM_2

     

    I2_SYS_ID

    H2_SYS_ID

    (foreign key referencing H2_SYS_ID in IN_TABLE_HEAD_2)

    ITEM_CODE

    I2ID1

    H2ID1

    I1

    I2ID2

    H2ID1

    I200

    I2ID3

    H2ID2

    I2

    IN_TABLE_BATCH_2

     

    B2_SYS_ID

    I2_SYS_ID

    (foreign key referencing I2_SYS_ID in IN_TABLE_ITEM_2)

    BAT_NO

    B2ID1

    I2ID1

    B30 / null

    B2ID2

    I2ID2

    B90

    B2ID2

    I2ID3

    B60

    IN_TABLE_HEAD_3

     

    H3_SYS_ID

    (primary key)

    TXN_CODE

    DOC_NO

    DOC_DATE

    H3ID1

    T50

    1234

    JANUARY 2, 2015

    H3ID2

    T80

    1234

    JANUARY 3, 2015

    H3ID3

    T90

    1234

    JANUARY 4, 2015

    H3ID4

    T40

    1234

    AUGUST 5, 2015

    IN_TABLE_ITEM_3

     

    I3_SYS_ID

    H3_SYS_ID

    (foreign key referencing H3_SYS_ID in IN_TABLE_HEAD_3)

    ITEM_CODE

    BAT_NO

    I3ID1

    H31D1

    I2

    B50

    I3ID2

    H3ID2

    I4

    B40

    I3ID3

    H3ID3

    I4

    I3ID4

    H3ID4

    I6

    There is no IN_TABLE_BATCH_3

    Please find below the expected results.

    OUTPUT

     

    ITEM_CODE

    BAT_NO

    TXN_CODE

    DOC_NO

    BOE_DT

    BATCH_YN

    I1

    B1

    T1

    1234

    JANUARY 3, 2015

    THERE

    I1

    B30

    T30

    7890

    FEBRUARY 5, 2015

    N

    I2

    B60

    T60

    1234

    JANUARY 3, 2015

    N

    I3

    B70

    T70

    1234

    FEBRUARY 1, 2015

    THERE

    I4

    T90

    1234

    JANUARY 4, 2015

    N

    I6

    T40

    1234

    AUGUST 5, 2015

    N

    Controls database to create the tables above and insert the records.

    CREATE TABLE stock_table()item_code VARCHAR2()80),bat_no VARCHAR2()80),txn_code VARCHAR2()80),

    doc_no VARCHAR2 (80), boe_dt DATE );

    INSERT EN stock_table

       VALUES ('I1', 'B1', '', '', '');

    INSERT EN stock_table

       VALUES ('I1', '', '', '', '');

    INSERT IN stock_table

       VALUES ('I2', '', '', '', '');

    INSERT EN stock_table

       VALUES ('I3', 'B70', '', '', '');

    INSERT EN stock_table

       VALUES ('I4', 'B80', '', '', '');

    INSERT EN stock_table

       VALUES ('I5', 'B90', 'T102', '1234', '02-JUL-2015');

    INSERT EN stock_table

       VALUES ('I6', 'B100', '', '', '');

    SELECT *

    FROM stock_table




     

    CREATE TABLE history_table()item_code VARCHAR2()80),bat_no VARCHAR2()80),txn_code VARCHAR2()80),

    doc_no VARCHAR2 (80), updt_dt DATE );

    INSERT IN history_table

       VALUES ('I1', 'B1', 'T1', '1234', '03-JAN-2015');

    INSERT IN history_table

       VALUES ('I1', 'B20', 'T20', '4567', '03-MAR-2015');

    INSERT IN history_table

       VALUES ('I1', 'B30', 'T30', '7890', '05-FEB-2015');

    INSERT IN history_table

       VALUES ('I2', 'B40', 'T20', '1234', '01-JAN-2015');

    SELECT *

    FROM history_table




     

    CREATE TABLE transaction1()txn_code VARCHAR()80),txn_type VARCHAR()80));


    INSERT INTO transaction1

       VALUES ('T1', 'IN');


    INSERT INTO transaction1

       VALUES ('T20', 'OUT');

    INSERT INTO transaction1

       VALUES ('T30', 'ALL');

    INSERT INTO transaction1

       VALUES ('T40', 'ALL');

    INSERT INTO transaction1

       VALUES ('T50', 'IN');

    INSERT INTO transaction1

       VALUES ('T60', 'ALL');

    INSERT INTO transaction1

       VALUES ('T70', 'ALL');

    INSERT INTO transaction1

       VALUES ('T80', 'IN');

    INSERT INTO transaction1

       VALUES ('T90', 'IN');

    SELECT *

    FROM transaction1




     

    CREATE TABLE in_table_head_1()h1_sys_id VARCHAR2()80) PRIMARY KEY,txn_code VARCHAR2()80),

    doc_no VARCHAR2 (80), doc_dt DATE );

    CREATE TABLE in_table_head_2()h2_sys_id VARCHAR2()80) PRIMARY KEY,txn_code VARCHAR2()80),

    doc_no VARCHAR2 (80), doc_dt DATE );

    CREATE TABLE in_table_head_3()h3_sys_id VARCHAR2()80) PRIMARY KEY,txn_code VARCHAR2()80),

    doc_no VARCHAR2 (80), doc_dt DATE );

     

    INSERT IN in_table_head_1

       VALUES ('H1ID1', 'T1', '1234', '01-JAN-2015');

    INSERT IN in_table_head_1

       VALUES ('H1ID2', 'T70', '1234', '01-FEB-2015');

    INSERT IN in_table_head_2

       VALUES ('H2ID1', 'T30', '4567', '03-FEB-2015');

    INSERT IN in_table_head_2

       VALUES ('H2ID2', 'T60', '1234', '03-JAN-2015');

    INSERT IN in_table_head_3

       VALUES ('H3ID1', 'T50', '1234', '02-JAN-2015');

    INSERT IN in_table_head_3

       VALUES ('H3ID2', 'T80', '1234', '03-JAN-2015');

    INSERT IN in_table_head_3

       VALUES ('H3ID3', 'T90', '1234', '05-JAN-2015');

    INSERT IN in_table_head_3

       VALUES ('H3ID4', 'T40', '1234', '05-AUG-2015');




     

    CREATE TABLE in_table_item_1()i1_sys_id VARCHAR2()80) PRIMARY KEY,

    h1_sys_id VARCHAR2 (80) REFERENCES in_table_head_1()h1_sys_id),item_code VARCHAR2()80));

    CREATE TABLE in_table_item_2()i2_sys_id VARCHAR2()80) PRIMARY KEY,

    h2_sys_id VARCHAR2 (80) REFERENCES in_table_head_2()h2_sys_id),item_code VARCHAR2()80));

    CREATE TABLE in_table_item_3(i3_sys_id VARCHAR2(80) PRIMARY KEY,

    h3_sys_id VARCHAR2 (80) REFERENCES in_table_head_3()h3_sys_id),item_code VARCHAR2()80),

    bat_no VARCHAR2 (80));

     

    INSERT IN in_table_item_1

       VALUES ('I1ID1', 'H1ID1', 'I1');

    INSERT IN in_table_item_1

       VALUES ('I1ID2', 'H1ID1', 'I100');

    INSERT IN in_table_item_1

       VALUES ('I1ID3', 'H1ID2', 'I3');

    INSERT IN in_table_item_2

       VALUES ('I2ID1', 'H2ID1', 'I1');

    INSERT IN in_table_item_2

       VALUES ('I2ID2', 'H2ID1', 'I200');

    INSERT IN in_table_item_2

       VALUES ('I2ID3', 'H2ID2', 'I2');

    INSERT IN in_table_item_3

       VALUES ('I3ID1', 'H3ID1', 'I2','B50');

    INSERT IN in_table_item_3

       VALUES ('I3ID2', 'H3ID2', 'I4','B40');

    INSERT IN in_table_item_3

       VALUES ('I3ID3', 'H3ID3', 'I4','');

    INSERT IN in_table_item_3

       VALUES ('I3ID4', 'H3ID4', 'I6','');

    SELECT *

    FROM in_table_item_1

    SELECT *

    FROM in_table_item_2

    SELECT *

    FROM in_table_item_3




     

    CREATE TABLE in_table_batch_1()b1_sys_id VARCHAR2()80) PRIMARY KEY,

    txn_code VARCHAR2 (80), doc_no VARCHAR2 (80), bat_no VARCHAR2 (80));

    CREATE TABLE in_table_batch_2()b2_sys_id VARCHAR2()80) PRIMARY KEY,

    i2_sys_id VARCHAR2 (80) REFERENCES in_table_item_2()i2_sys_id),bat_no VARCHAR2()80));

     

    INSERT IN in_table_batch_1

       VALUES ('B1ID1', 'T1', '1234', 'B1');

    INSERT IN in_table_batch_1

       VALUES ('B1ID2', 'T70', '1234', 'B70');

    INSERT IN in_table_batch_2

       VALUES ('B2ID1', 'I2ID1', 'B30');

    INSERT IN in_table_batch_2

       VALUES ('B2ID2', 'I2ID2', 'B90');

    INSERT IN in_table_batch_2

       VALUES ('B2ID3', 'I2ID3', 'B60');

    Please advise a solution for the same.

    Thank you and best regards,

    Séverine Suresh

    very forced (question subfactoring used to allow easy testing/verification - could work with these test data only)

    with

    case_1 as

    (select s.item_code,

    s.bat_no,

    h.txn_code,

    h.doc_no,

    h.updt_dt boe_dt,

    cases where s.bat_no = h.bat_no then 'Y' else ' n end batch_yn.

    cases where h.txn_code is not null

    and h.doc_no is not null

    and h.updt_dt is not null

    then 'case 1' '.

    end refers_to

    from (select item_code, bat_no, txn_code, doc_no, boe_dt

    of w_stock_table

    where bat_no is null

    or txn_code is null

    or doc_no is null

    or boe_dt is null

    ) s

    left outer join

    w_history_table h

    On s.item_code = h.item_code

    and s.bat_no = h.bat_no

    and exists (select null

    of w_transaction1

    where txn_code = nvl (s.txn_code, h.txn_code)

    and txn_type in ('IN', 'ALL')

    )

    ),

    case_2 as

    (select s.item_code,

    NVL (s.bat_no, h.bat_no) bat_no.

    NVL (s.txn_code, h.txn_code) txn_code.

    NVL (s.doc_no, h.doc_no) doc_no.

    NVL (s.boe_dt, h.updt_dt) updt_dt.

    cases where s.bat_no = h.bat_no then 'Y' else ' n end batch_yn.

    cases where h.txn_code is not null

    and h.doc_no is not null

    and h.updt_dt is not null

    then 'case 2'.

    end refers_to

    from (select item_code, bat_no, txn_code, doc_no, boe_dt

    of case_1

    where refers_to is null

    ) s

    left outer join

    w_history_table h

    On s.item_code = h.item_code

    and exists (select null

    of w_transaction1

    where txn_code = nvl (s.txn_code, h.txn_code)

    and txn_type in ('IN', 'ALL')

    )

    and not exists (select null

    of case_1

    where item_code = h.item_code

    and bat_no = h.bat_no

    and txn_code = h.txn_code

    and doc_no = h.doc_no

    and updt_dt = h.updt_dt

    )

    ),

    case_31 as

    (select s1.item_code,

    NVL (S1.bat_no, W1.bat_no) bat_no.

    NVL (S1.txn_code, W1.txn_code) txn_code.

    NVL (S1.doc_no, W1.doc_no) doc_no.

    NVL (S1.updt_dt, W1.doc_dt) updt_dt.

    cases where s1.bat_no = w1.bat_no then 'Y' else ' n end batch_yn.

    cases where w1.txn_code is not null

    and w1.doc_no is not null

    and w1.doc_dt is not null

    then "case 31'.

    end refers_to

    from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn, refers_to

    of case_2

    where refers_to is null

    ) s1

    left outer join

    (select i1.item_code, h1.txn_code, h1.doc_no, h1.doc_dt, b1.bat_no

    of w_in_table_item_1 i1

    inner join

    w_in_table_head_1 h1

    On i1.h1_sys_id = h1.h1_sys_id

    inner join

    w_in_table_batch_1 b1

    On h1.txn_code = b1.txn_code

    and h1.doc_no = b1.doc_no

    ) w1

    On s1.item_code = w1.item_code

    ),

    case_32 as

    (select s2.item_code,

    NVL (S2.bat_no, W2.bat_no) bat_no.

    NVL (S2.txn_code, W2.txn_code) txn_code.

    NVL (S2.doc_no, W2.doc_no) doc_no.

    NVL (S2.updt_dt, W2.doc_dt) updt_dt.

    cases where s2.bat_no = w2.bat_no then 'Y' else ' n end batch_yn.

    cases where w2.txn_code is not null

    and w2.doc_no is not null

    and w2.doc_dt is not null

    then "case 32'.

    end refers_to

    from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn, refers_to

    of case_2

    where refers_to is null

    ) s2

    left outer join

    (select i2.item_code, h2.txn_code, h2.doc_no, h2.doc_dt, b2.bat_no

    of w_in_table_item_2 i2

    inner join

    w_in_table_head_2 h2

    On i2.h2_sys_id = h2.h2_sys_id

    inner join

    w_in_table_batch_2 b2

    On i2.i2_sys_id = b2.i2_sys_id

    ) w2

    On s2.item_code = w2.item_code

    ),

    case_33 as

    (select s3.item_code,

    w3.bat_no,

    NVL (S3.txn_code, w3.txn_code) txn_code.

    NVL (S3.doc_no, w3.doc_no) doc_no.

    NVL (S3.updt_dt, w3.doc_dt) updt_dt.

    cases where s3.bat_no = w3.bat_no then 'Y' else ' n end batch_yn.

    cases where w3.txn_code is not null

    and w3.doc_no is not null

    and w3.doc_dt is not null

    then "case 33'.

    end refers_to

    from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn, refers_to

    of case_2

    where refers_to is null

    ) s3

    left outer join

    (select i3.item_code, h3.txn_code, h3.doc_no, h3.doc_dt, i3.bat_no

    of w_in_table_item_3 i3

    inner join

    w_in_table_head_3 h3

    On i3.h3_sys_id = h3.h3_sys_id

    ) w3

    On s3.item_code = w3.item_code

    )

    Select item_code, bat_no, txn_code, doc_no, boe_dt, batch_yn

    of case_1

    where refers_to is not null

    Union of all the

    Select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn

    of case_2

    where refers_to is not null

    Union of all the

    Select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn

    from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn,

    ROW_NUMBER() over (partition by item_code of updt_dt desc order) rn

    from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn

    of case_31

    where refers_to is not null

    Union of all the

    Select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn

    of case_32

    where refers_to is not null

    Union of all the

    Select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn

    of case_33

    where refers_to is not null

    )

    )

    where rn = 1

    ITEM_CODE BAT_NO TXN_CODE DOC_NO BOE_DT BATCH_YN
    I1 B1 T1 1234 JANUARY 3, 2015 THERE
    I1 B30 T30 7890 FEBRUARY 5, 2015 N
    I2 B60 T60 1234 JANUARY 3, 2015 N
    I3 B70 T70 1234 FEBRUARY 1, 2015 THERE
    I4 - T90 1234 JANUARY 5, 2015 N
    I6 - T40 1234 AUGUST 5, 2015 N

    Concerning

    Etbin

  • Table error ' can not analyze the SQL query!

    Hi all

    I created a view on my database called VIEW_MEMBER_PARTIC_PROJECTS

    If I run a query showing the results of the view:

    SELECT * FROM VIEW_MEMBER_PARTIC_PROJECTS

    I get the following data

    ProjectsParticipants
    131 S
    241
    319
    43
    53
    61
    72

    Now, I wanted to represent this diagram in the APEX so I created a graphic region and entered the Source query generator and the manufacturer produces the following code

    Select null, label projects, value1 Participant link

    of "SCHEMANAME." "" VIEW_MEMBER_PARTIC_PROJECTS ".

    With this code, I get an error:

    Cannot parse the SQL query!

    Select the link null, label projects, value1 "SCHEMANAME Participant." "" VIEW_MEMBER_PARTIC_PROJECTS ".

    Some queries can be run when you run your application, if your query is syntactically correct, you can save your query without validation (see options below the source of the query).

    The code looks OK, but I do not see to save options as the error code is mentioned.

    No one knows how to fix this?

    Thank you

    JaReg wrote:

    I finally found the problem.

    I looked at the code for the view and changed the start of:

    CREATE OR REPLACE FORCE EDITIONABLE VIEW "SCHEMANAME." "" VIEW_MEMBER_PARTIC_PROJECTS "("Participant","Projects")

    AS

    TO

    CREATE OR REPLACE VIEW "SCHEMANAME." "" VIEW_REPEAT_PARATIC ".

    AS

    And that seemed to fix it. I'm not entirely sure why though.

    The view was created using the quoted identifiers for column names. This makes them sensitive and means that they must always be referenced using double quotes. In the absence of quotation marks, Oracle is not case insensitive and automatically converts all uppercase identifiers. The application of graph:

    Select the link null, label projects, value1 "SCHEMANAME Participant." "" VIEW_MEMBER_PARTIC_PROJECTS ".

    has therefore been interpreted by Oracle:

    SELECT THE LINK NULL, LABEL, VALUE1 "SCHEMANAME PARTICIPANT PROJECTS." "" VIEW_MEMBER_PARTIC_PROJECTS ".

    and PROJECTS and PARTICIPANT columns were not recognized because the columns defined for the view have been 'Participant' and 'projects '. The graphic request should have been:

    Select the link null, the label of "Projects", "Participant" value1 "SCHEMANAME." "" VIEW_MEMBER_PARTIC_PROJECTS ".

    As you have now discovered, quoted identifiers are a source of nothing but obscure bugs and should never be used for database objects. He also pointed out the reason why you should always use a standardized, form tiny, coding style as it is faster to type, easy to read and less prone to errors.

  • I have a HP officejet V40 and have lost the driver cd could you let me know an address where I can download a free driver for this please? thanks___Andydeee __many.,.

    Remember - this is a public forum so never post private information such as numbers of mail or telephone!

    Ideas:

    • You have problems with programs
    • Error
    • I have a HP officejet V40 and have lost the driver cd could you let me know an address where I can download a free driver for this please?
    • Thank you very much
    • Andydeee.,.
    • Recent changes to your computer
    • What you have already tried to solve the problem

    http://h20180.www2.HP.com/apps/lookup?h_lang=en&h_cc=us&cc=us&h_page=hpcom&lang=en&h_client=S-A-R163-1&h_pagetype=s-002&h_query=HP+OfficeJet+v40&submit.x=5&submit.y=5

    Go to the above link > click your printer model > then your particular operating system > and then the HP reading tips.

    See you soon.

    Mick Murphy - Microsoft partner

  • SQL query for the apex report

    Hi team,

    For example if I have a demo table with 4 columns (A, B, C, D) DEMO.

    I want a report on this table, such that the report contains the headers and the Details section.

    For each unique combination of (A, B) I must first of all show header based on the header information I want to display the detailed section.
    In my header section I want to display 2 columns (A, B) that are common to the detailed section. Remaining 2 columns in the detailed section.


    Here is an example: -.

    A B C D
    1 5 9 3
    1 5P8
    1 5 P O
    1-5-9
    1 8 9
    1     D     *     /
    2 8 33 P
    2 P O O
    2 P L L

    YOU WILL SEE
    A AND B
    1 5

    C D
    9 3
    P 8
    P O


    A AND B
    1 D

    C D
    5 9
    8 9
    *     /



    A AND B
    2 P

    C D
    8 33
    O O
    L L

    Please suggest the solution (sql query) for above the problem and how to nest gernerated headers dynamically in the report area.
    I use APEX 4.0
    Any position in this regard is very significant.

    Thanks and greetings
    Rajendra

    Try this:

    SQL> select * from tab;
    1 5 9 3
    1 5 P 8
    1 5 P O
    1 D 5 9
    1 D 8 9
    1 P 8 3
    1 P O O
    
    7 rows selected.
    
    SQL> select a,b from
    (select r,a,b from
    ( select to_char(rownum)||'a' r, 'A' a,'B' b from
            (select distinct a, b from tab order by a,b))
            union
    ( select to_char(rownum)||'c' r, 'C' c,'D' d from
            (select distinct a, b from tab order by a,b))
    union
    ( select to_char(rownum)||'b' r, a,b from
    (select distinct a, b from tab order by a,b))
    union
    select parent.r, tab.c, tab.d from
    ( select to_char(rownum)||'d' r, a,b from
    (select distinct a, b from tab order by a,b)) parent ,
    tab
    where parent.a=tab.a and
    parent.b=tab.b
    ) order by r
    ;
    A B
    1 5
    C D
    9 3
    P 8
    P O
    A B
    1 D
    C D
    5 9
    8 9
    A B
    1 P
    C D
    8 3
    O O
    
  • Is there a way I can personally verify my I Pad Pro to see if it has been refurbished, because I paid the FULL PRICE $$$ for this but have not begun it upwards again and I have a suspicion, it is refurbished? Can I bring to an APPLE STORE and have it chec

    Is there a way I can personally verify my I Pad Pro to see if it has been refurbished, because I paid the FULL PRICE $$$ for this but have not begun it upwards again and I have a suspicion, it is refurbished! Can I bring to an APPLE STORE and have them check for me?

    * Because if it is I never purchases in this store ever again, but I WANT it CHEKED OUT by myself if I can.

    Please help as soon as POSSIBLE due to delays return date.

    Thank you all

    Makes you think about the iPad Pro you received is a refurb?

    Apple, general, selling and shipping of refurb in the plain, non-description boxes/packages.

  • What is the maximum memory for this computer what kind

    I want to restore my system like new or factory but I have no disk what the best thing to do and what is the maximum memory for this computer, what type and how much slot I only see 2 slots without any, but the system say that this computer has 512 MB of ram. This model says Dell Dimension8100. Thank you.

    What is the maximum memory for this computer, what type and how much slot I only see 2 slots without any, but the system say that this computer has 512 MB of ram. This model says Dell Dimension8100. Thank you.

    Maximum RAM 2 GB

    http://support.Dell.com/support/eDOCS/systems/dsleest/specs.htm#memory

    Note: the manufacturer was required to provide a way to reinstall Windows. If it is not a set of disks with the computer, there will be a hidden restore partition (do not be confused with the system restore), you would use to return the computer to the State of the OOBE (Out of Box Experience).

    Usually, just by pressing F11 continuously during the computer startup to display a boot menu offering the option you need.

    You may need to contact the manufacturer of your hardware (Dell) to see what options they have to repair Windows.

    UTC/GMT is 20:35 on Saturday, May 26, 2012

Maybe you are looking for

  • How I change my home page?

    I want my portfolio on yahoo/finance as my home page. How can I created this?

  • NB300 - Windows not genuine message

    I have a 2 GB of ram, the origin of the bios nb300 v 1.5 that worked. Recently, I got windows message notauthentic, I then tried to restore the computer to the State of the box, using media, created tofirst commissioning, when I bought NB300 and now

  • Speed of the satellite - 12L - C850D slow WLAN and LAN

    Help please I C850D - 12L running Windows 8.1 and as far as I know, have all drivers up to date according to PC world. I am not receiving the correct speeds both hard and connectivity wireless. Should get 30 + bottom and 10 upward but getting 10 down

  • Satellite A30 - shuts down during the installation of recovery or FDISK

    I have a Satellite A30 and I wanted all off it delete and start from scratch. Turned back with disc 1 CD product recovery, started well I was prompted to insert disk 2, it does well to about 80% then erased screen, then got the message "invalid parti

  • F4j00la #akh: Problemas con HP Pavilion 15 Wifi

    I have a HP Pavilion 15, lo compre hace approximately 7 meses y some veces me habia dado wifi conexion problemas, pero nunca tanto como ahora.The conexion me appears como 'limitada '. Tengo mas on devices connected a wifi este además y ninguno tiene