Oracle complicated query pls help

create table  PQ02(PQ02_NUM,PQ02_LIGN,PQ02_TYP_OPER_BLN,PQ02_CHMP,PQ02_VAL_CRIT)

Insert into PQ02 (PQ02_NUM,PQ02_LIGN,PQ02_TYP_OPER_BLN,PQ02_CHMP,PQ02_VAL_CRIT) values (4072,1,null,'VIP1_DAT_MONT','''2008''');
Insert into PQ02 (PQ02_NUM,PQ02_LIGN,PQ02_TYP_OPER_BLN,PQ02_CHMP,PQ02_VAL_CRIT) values (4072,2,'AND       ',null,null);
Insert into PQ02 (PQ02_NUM,PQ02_LIGN,PQ02_TYP_OPER_BLN,PQ02_CHMP,PQ02_VAL_CRIT) values (4072,3,'NOT       ',null,null);
Insert into PQ02 (PQ02_NUM,PQ02_LIGN,PQ02_TYP_OPER_BLN,PQ02_CHMP,PQ02_VAL_CRIT) values (4072,4,'(         ',null,null);
Insert into PQ02 (PQ02_NUM,PQ02_LIGN,PQ02_TYP_OPER_BLN,PQ02_CHMP,PQ02_VAL_CRIT) values (4072,5,'(         ',null,null);
Insert into PQ02 (PQ02_NUM,PQ02_LIGN,PQ02_TYP_OPER_BLN,PQ02_CHMP,PQ02_VAL_CRIT) values (4072,6,'(         ',null,null);
Insert into PQ02 (PQ02_NUM,PQ02_LIGN,PQ02_TYP_OPER_BLN,PQ02_CHMP,PQ02_VAL_CRIT) values (4072,7,null,'RF23_LIB_MARQ_DIS','''INFINITY''');
Insert into PQ02 (PQ02_NUM,PQ02_LIGN,PQ02_TYP_OPER_BLN,PQ02_CHMP,PQ02_VAL_CRIT) values (4072,8,')         ',null,null);
Insert into PQ02 (PQ02_NUM,PQ02_LIGN,PQ02_TYP_OPER_BLN,PQ02_CHMP,PQ02_VAL_CRIT) values (4072,9,')         ',null,null);
Insert into PQ02 (PQ02_NUM,PQ02_LIGN,PQ02_TYP_OPER_BLN,PQ02_CHMP,PQ02_VAL_CRIT) values (4072,10,'AND       ',null,null);
Insert into PQ02 (PQ02_NUM,PQ02_LIGN,PQ02_TYP_OPER_BLN,PQ02_CHMP,PQ02_VAL_CRIT) values (4072,11,'(         ',null,null);
Insert into PQ02 (PQ02_NUM,PQ02_LIGN,PQ02_TYP_OPER_BLN,PQ02_CHMP,PQ02_VAL_CRIT) values (4072,12,'(         ',null,null);
Insert into PQ02 (PQ02_NUM,PQ02_LIGN,PQ02_TYP_OPER_BLN,PQ02_CHMP,PQ02_VAL_CRIT) values (4072,13,null,'RF73_COD_PIV_BOI','''CVT''');
Insert into PQ02 (PQ02_NUM,PQ02_LIGN,PQ02_TYP_OPER_BLN,PQ02_CHMP,PQ02_VAL_CRIT) values (4072,14,')         ',null,null);
Insert into PQ02 (PQ02_NUM,PQ02_LIGN,PQ02_TYP_OPER_BLN,PQ02_CHMP,PQ02_VAL_CRIT) values (4072,15,'OR        ',null,null);
Insert into PQ02 (PQ02_NUM,PQ02_LIGN,PQ02_TYP_OPER_BLN,PQ02_CHMP,PQ02_VAL_CRIT) values (4072,16,'(         ',null,null);
Insert into PQ02 (PQ02_NUM,PQ02_LIGN,PQ02_TYP_OPER_BLN,PQ02_CHMP,PQ02_VAL_CRIT) values (4072,17,null,'RF73_COD_PIV_BOI','''DCT''');
Insert into PQ02 (PQ02_NUM,PQ02_LIGN,PQ02_TYP_OPER_BLN,PQ02_CHMP,PQ02_VAL_CRIT) values (4072,18,')         ',null,null);
Insert into PQ02 (PQ02_NUM,PQ02_LIGN,PQ02_TYP_OPER_BLN,PQ02_CHMP,PQ02_VAL_CRIT) values (4072,19,')         ',null,null);
Insert into PQ02 (PQ02_NUM,PQ02_LIGN,PQ02_TYP_OPER_BLN,PQ02_CHMP,PQ02_VAL_CRIT) values (4072,20,')         ',null,null);
Select * from pq02


I have to put the query and get the result as below

based on conditions that

(1) PQ02_TYP_OPER_BLN EXPECTED TO HAVE 3 OPEN BRACKETS (((IN ROW. IT IS HERE PQ02_LIGN 4,5,6
(2) the previous line (((ne doit PAS.)) HERE, IT IS PQ02_LIGN 3
PQ02_TYP_OPER_BLN 3) SHOULD HAVE 3 closed FLANGES))). This is where the 18,19,20


I want the records between these rows. It's like NOT (())

IN the MEANTIME, THESE ROWS I WANT THE VALUES only values rf73, Q02_VAL_CRIT "FPC", "DCT".

Pls help
s

Hello

Of course, you can do it.

If you don't want these spaces, then
(a) do not put them in the table in the first place, or
(b) use RTRIM to remove them before forming the txt

If you don't want pq02_typ_oper_bln to appear in txt, then don't mention pq02_typ_oper_bln in the formation of txt.
The parentheses are important, however. It seems that the output would be ambiguous without them.

If you want PQ02_CHMP, followed of '=' followed by PQ02_VAL_CRIT where I used only PQ02_CHMP, then replace PQ02_CHMP with

PQ02_CHMP || ' = ' || PQ02_VAL_CRIT

during the formation of txt.

Tags: Database

Similar Questions

  • Due to the lack of days query... Pls Help gurus

    I have a table that stores the presence information

    For example:

    Date of Emp_No
    100 APRIL 1, 2010
    102 APRIL 5, 2010
    100 APRIL 2, 2010


    I need a query with parameters from Date and to date...


    My query result should be like this... given that 100 employee is absent for 8 days straight and employee number 102 is absent for 2 consecutive days...
    It should return the number of consecutive days, he hasn't.

    EmpNo consecutive days
    100 8 days
    102 days 2


    Pls help gurus.

    Published by: suzvino on June 21, 2010 12:14 AM
    TUBBY_TUBBZ?with data as
      2  (
      3     select 100 as emp_no, to_date('01-APR-2010','dd-mon-yyyy') as absent_date from dual union all
      4     select 102 as emp_no, to_date('05-APR-2010','dd-mon-yyyy') as absent_date from dual union all
      5     select 100 as emp_no, to_date('02-APR-2010','dd-mon-yyyy') as absent_date from dual union all
      6     select 100 as emp_no, to_date('01-APR-2010','dd-mon-yyyy') as absent_date from dual union all
      7     select 100 as emp_no, to_date('03-APR-2010','dd-mon-yyyy') as absent_date from dual union all
      8     select 100 as emp_no, to_date('04-APR-2010','dd-mon-yyyy') as absent_date from dual union all
      9     select 100 as emp_no, to_date('05-APR-2010','dd-mon-yyyy') as absent_date from dual union all
     10     select 100 as emp_no, to_date('06-APR-2010','dd-mon-yyyy') as absent_date from dual union all
     11     select 100 as emp_no, to_date('07-APR-2010','dd-mon-yyyy') as absent_date from dual union all
     12     select 100 as emp_no, to_date('08-APR-2010','dd-mon-yyyy') as absent_date from dual union all
     13     select 100 as emp_no, to_date('09-APR-2010','dd-mon-yyyy') as absent_date from dual
     14  )
     15  select
     16     emp_no, max(level)
     17  from data
     18  connect by prior emp_no = emp_no and prior absent_date = absent_date - 1
     19  group by emp_no
     20  having max(level) >= 8;
    
                EMP_NO         MAX(LEVEL)
    ------------------ ------------------
                   100                  9
    
    1 row selected.
    
    Elapsed: 00:00:00.01
    TUBBY_TUBBZ?
    

    Think that I misread the post, the request should be

    TUBBY_TUBBZ?with data as
      2  (
      3     select 100 as emp_no, to_date('01-APR-2010','dd-mon-yyyy') as absent_date from dual union all
      4     select 102 as emp_no, to_date('05-APR-2010','dd-mon-yyyy') as absent_date from dual union all
      5     select 100 as emp_no, to_date('02-APR-2010','dd-mon-yyyy') as absent_date from dual union all
      6     select 100 as emp_no, to_date('01-APR-2010','dd-mon-yyyy') as absent_date from dual union all
      7     select 100 as emp_no, to_date('03-APR-2010','dd-mon-yyyy') as absent_date from dual union all
      8     select 100 as emp_no, to_date('04-APR-2010','dd-mon-yyyy') as absent_date from dual union all
      9     select 100 as emp_no, to_date('05-APR-2010','dd-mon-yyyy') as absent_date from dual union all
     10     select 100 as emp_no, to_date('06-APR-2010','dd-mon-yyyy') as absent_date from dual union all
     11     select 100 as emp_no, to_date('07-APR-2010','dd-mon-yyyy') as absent_date from dual union all
     12     select 100 as emp_no, to_date('08-APR-2010','dd-mon-yyyy') as absent_date from dual union all
     13     select 100 as emp_no, to_date('09-APR-2010','dd-mon-yyyy') as absent_date from dual
     14  )
     15  select
     16     emp_no, max(level)
     17  from data
     18  connect by prior emp_no = emp_no and prior absent_date = absent_date - 1
     19  group by emp_no;
    
                EMP_NO         MAX(LEVEL)
    ------------------ ------------------
                   100                  9
                   102                  1
    
    2 rows selected.
    
    Elapsed: 00:00:00.01
    

    Published by: Tubby 30 May 2010 23:00

    Second additional query because I misread the post originally.

  • Pls help me in creating a view

    Hi all

    We have a few tables in Oracle HRMS, per_jobs table gives details of all defined jobs,
    PAY_JOB_WC_CODE_USAGES table contains all the compensation codes defined and PAY_STATE_RULES
    table contains all status codes.

    Now SELECT WC. STATE_CODE,
    PJ. JOB_ID,
    PSR.NAME STATE_NAME,
    PJ.NAME JOB_NAME
    OF per_jobs pj,.
    PAY_JOB_WC_CODE_USAGES WC,
    ESP PAY_STATE_RULES
    WHERE PJ. JOB_ID (+) IS WC. JOB_ID
    AND WC. STATE_CODE (+) IS ESP. STATE_CODE
    This query gives the job_names that are defined in a State...

    But, now, is what I want

    I want to get the names of work that are not defined in each State for this I want to create a view
    So, could u pls help me to write this query.

    Example,
    SELECT * FROM PER_JOBS
    If job_id in (select job_id from PAY_JOB_WC_CODE_USAGES where STATE_CODE = "GO")
    This will give you the details on employment that are not defined in the State called "WILL"...

    But I want that all the jobs that are not defined in all States...

    Thank you
    select psr.state_code, pj.*
      from per_jobs pj
          ,pay_job_wc_code_usages wc
          ,pay_state_rules psr
     where pj.job_id = wc.job_id
       and not exists (select 1 from pay_job_wc_code_usages wc1
                        where wc1.job_id = pj.job_id
                          and wc1.state_code = psr.state_code);
    

    I think that could do it. Not tested.

  • value of constant column pls help

    COL cnt noprint
    
    COLUMN  cnt NEW_VALUE rowcount
    I use this to a query select as below
    ROWNUM cnt, COUNT (*) OVER () cnt
    but it's the null return lines... This number of lines is not initilized.

    while I'm usng for supplementary registration
    SELECT '* Trailer record *' || '|' || &rowcount
      FROM DUAL
    It is giving error as below

    OF THE DOUBLE
    *
    ERROR on line 2:
    ORA-00936: lack of expression

    Pls help

    S

    but you both take values as
    where 1 = 0

    We are simulating a query that does not return any line: your query should be used instead:

    col cnt noprint
    
    column cnt new_value rowcount
    
    select voucher_id,  .....
            COUNT (*) OVER () cnt
     from  table name
    / 
    
    select '* Trailer record *' || '|' || nvl('&rowcount', 0)  from dual
    / 
    

    By the way: you used two columns in your query, two of them named CNT (and both do basically the same thing)-> you should avoid that.

  • ORA-06512, ora-04088 pls help

    version database - Oracle Database 10 g Enterprise Edition Release 10.2.0.3.0

    Hi I create a trigger.

    create or replace TRIGGER INSERT_STOCK_RECORDS
    AFTER INSERTION
    ON MAKESS. MST_ITEM
    FOR EACH LINE
    DECLARE
    fin_start_date DATE;
    fin_end_date DATE;
    BEGIN
    BEGIN
    SELECT dt_current_start_date, dt_current_end_date
    IN fin_start_date, fin_end_date
    OF finance.fin_account_year
    WHERE vc_comp_code =:NEW.vc_comp_code
    AND ch_year_closing_flag = 'o';
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    SELECT dt_current_start_date, dt_current_end_date
    IN fin_start_date, fin_end_date
    OF finance.fin_account_year
    WHERE vc_comp_code =:NEW.vc_comp_code
    AND ch_year_closing_flag = 'C ';

    WHILE OTHERS THEN
    RAISE_APPLICATION_ERROR (-20101, 'Error encountered with your exercise');
    END;


    (- 1).
    INSERT INTO invent.stock_summary
    (vc_comp_code, vc_item_code, NU_BALANCE_QTY, NU_QTY_REJECTED,
    NU_QTY_REWORKABLE, NU_QTY_DEFECTIVE, NU_QTY_ORDERED, NU_QTY_REQUESTED
    NU_QTY_TO_ORD, NU_QTY_AVAILABLE, NU_QTY_REQUIRED, vc_default_comp)
    VALUES (: NEW.vc_comp_code,: NEW.vc_item_code, NVL(:NEW.nu_opening_qty,0), 0,)
    0, 0, 0, 0.
    0, NVL(:NEW.nu_opening_qty,0), 0,: NEW.vc_default_comp);
    (- 2).
    INSERT INTO production.prod_stock
    (vc_comp_code, NU_AREA_CODE, vc_item_code, NU_BALANCE_QTY, NU_QTY_REJECTED,
    NU_QTY_REWORKABLE, NU_QTY_DEFECTIVE, NU_QTY_ORDERED, NU_QTY_REQUESTED
    NU_QTY_TO_ORD, NU_QTY_AVAILABLE, nu_qty_required, vc_default_comp)
    VALUES (: NEW.vc_comp_code, 1: NEW.vc_item_code, 0, 0)
    0, 0, 0, 0.
    0, 0, 0,:NEW.vc_default_comp);
    (- 3).
    INSERT INTO invent.stk_lot_summary
    (vc_comp_code, vc_item_code, NU_BALANCE_QTY, NU_QTY_REJECTED,
    NU_QTY_REWORKABLE, NU_QTY_DEFECTIVE, VC_LOT_NO, VC_BIN_NO, NU_COST, vc_default_comp)
    VALUES (: NEW.vc_comp_code,: NEW.vc_item_code, NVL(:NEW.nu_opening_qty,0), 0,)
    0, 0,: NEW.vc_lot_no,: NEW.vc_bin_no, NVL (: NEW .nu_eval_rate, 0),: NEW .vc_default_comp);

    (- 4).

    INSERT INTO invent.mst_month_summary
    (vc_comp_code, dt_fin_start_date, dt_fin_end_date, vc_item_code,
    nu_year_open_balance, nu_tot_received, vc_default_comp)
    VALUES (: NEW.vc_comp_code, fin_start_date, fin_end_date,: NEW.vc_item_code,)
    NVL(:New.nu_opening_qty,0), NVL(:NEW.nu_opening_qty,0),
    (: NEW.vc_default_comp);

    EXCEPTION
    WHILE OTHERS THEN
    RAISE_APPLICATION_ERROR (-20101, 'Error');
    END;

    but when I insert in this table, it is in error-

    INSERT INTO MST_ITEM (VC_DEFAULT_COMP, VC_COMP_CODE, VC_ITEM_CODE, VC_ITEM_DESC, VC_TECH_DESC, NU_BASIC_PRICE,
    NU_EVAL_RATE, NU_SCRAP_RATE, NU_WASTE_PER, VC_UNIT, VC_CLASSIFICATION, NU_OPENING_QTY, VC_ITEM_GROUP,
    VC_UNIT_CODE, VC_LOT_NO, VC_BIN_NO, DT_MOD_DATE, VC_AUTH_CODE, VC_ABC_CLASS, VC_VED_CLASS)
    VALUES ('01 ', ' 01', 'RMPR000025', 'NEW ITEM', 'NEW', 1, 1, 0, 0, "KGS, 'NEWT', 0, '23', '1', '1', '1', SYSDATE,' 01', 'A', 'V')
    /


    INSERT INTO MST_ITEM (VC_DEFAULT_COMP, VC_COMP_CODE, VC_ITEM_CODE, VC_ITEM_DESC, VC_TECH_DESC, NU_BASI
    *
    ERROR on line 1:
    ORA-20101: encountered error
    ORA-06512: at "MAKESS. INSERT_STOCK_RECORDS', line 58
    ORA-04088: error during execution of trigger ' MAKESS. ' INSERT_STOCK_RECORDS


    pls help me why this problem occurs.

    Hello

    ERROR on line 1:
    ORA-20101: encountered error

    What meaningful message...

    Please remove each WHEN of OTHER blocks in the exception handlers and let the real error.

  • PLS, help me to reset safari on mac Ox: 10.11.5

    PLS, help me to reset safari on mac Ox: 10.11.5

    What do you mean by reset.

  • I earsed my hd and now im trying to reinstall, but an error has occurred during installation, which means that I can't reinstall osx again. PLS HELP!

    I earsed my hd and now im trying to reinstall, but an error has occurred during installation, which means that I can't reinstall osx again. PLS HELP!

    Please tell us how wipe you the drive and how you tried to reinstall OS X. And what was the error, and how he help you trying to reinstall OSX again? You can look at writing an effective communities of Apple support question before you answer because we are not spirit or psychic readers.

  • looking for someone to help me with this problem. "It is no set application to open the document"stream_000b.strings ". "How can I get rid of him. pls help

    I get this message when I turn my macbook pro on "there is no set of application to open the document"stream_000b.strings ". "How can I get rid of him. pls help

    Check preferences system/users and groups to see if this item is in your login items. If so, select it and use the sign less to remove.

    If she is not there, see if you can find the file by using one of these programs. If you go Finder/display/show bar path, it will show you where it is located. You can then remove it.

    EasyFind-replacement of Spotlight

    Find any file

  • My Fire Fox download video in support not detected on you tube. It is always shows only the first video that i was downloaded.pls help

    My Fire Fox download video in support not detected on you tube. It is always shows only the first video that i was downloaded.pls help

    I don't think there is much you can do about it outside the use of workaround to reload the page until this problem is corrected.

    There is this bug on this problem:

    I don't know if other extensions download suffer from this issue, as well, so you can try a little more try the website of the add-on and if possible use a different format like WebM, if they are available.

    Also note that not all videos are downloaded and registered correctly. Some may have a size of 0 bytes and fail to download, so, best is to check in downloads of the toolbar Manager in the drop-down list to make sure that the file size is correct (i.e. neither 0 bytes, but a more likely size).

    YouTube streaming makes changes to the code and the way its web pages work, so extensions can fail at any time.

  • My Ethernet port is not running iMac mid 2011. Pls help me.

    Hi, I have an iMac 21.5 "mid-2011. My Ethernet port is not working. Is this a software problem? Pls help me.

    Try resetting the SMC reset management system (SCM) controller on your Mac - Apple Support

    Try another ethernet cable.

    He still does not? A report with the information more wrote an effective communities of Apple Support question

  • Problem with my iPhone 6s, while charging or using internet, he rejects a higher amount of heat! Pls help me...

    PProblem with my iPhone 6s, while charging or using internet, it rejects higher amoun of heat! Pls help me...

    Certain amount of heat is normal using a particularly intense use as a streaming video

    Can I restart a Force

    Restart your iPhone, iPad or iPod touch - Apple Support

    If the problem persists

    An appointment of 'Genius' to an Apple Store, or select another authorized service provider.

  • minimize, maximize the task .bar and close icons are missing.pls help.

    my homepage is google.but when I open firefox, I don't see it.i can't see maximize minimize andclose icons too. pls help.

    You can be in full screen - hit F11. It is re - appear?

  • I don't understand why I can't login my account using mozilla but with googlechrome fb, I am able to do... Mozilla can load the fb site but cannot access my fb account... I'm uncomfortable with the use of mozilla as my browser... pls help thanks

    I don't understand why I can't login my account using mozilla but with googlechrome fb, I am able to do... Mozilla can load the fb site but cannot access my fb account... I'm uncomfortable with the use of mozilla as my browser... pls help thanks

    • "Clear the Cache": Tools > Options > advanced > network > storage (Cache) offline: 'clear now '.
    • 'Delete Cookies' of sites that cause problems: Tools > Options > privacy > Cookies: "show the Cookies".

    Start Firefox in Firefox to solve the issues in Safe Mode to check if one of the Add-ons is the cause of the problem (switch to the DEFAULT theme: Tools > Modules > themes).

    • Makes no changes on the start safe mode window.

    See:

  • Pls help me with my computer hp mini laptop

    Pls help me with my computer hp mini laptop

    system disabled

    [69005685]

    Hello

    Try to enter: 76963201

    Kind regards

    DP - K

  • Pls help me how to fix my iphone 5 wifi is gray

    I do even the bits of Apple that reset freezer/hair dryer tips and network settings, but nothing happens pls help me...

    The iPhone has water damage?

    Has been jailbroken iPhone?

    What were you doing before that happened?

Maybe you are looking for

  • How to convert emails into a calendar entry

    In the past, I had a menu drop-down entry similar to 'move' features that allowed me to copy text from an email to a calendar entry.It seems to have disappeared?

  • How can I change my last name?

    How can I change my last name from my apple ID and also for my user account on my laptop (Administrator).

  • 1. to Stor.E TV - files are empty

    Hello I hope for your help. I have a 1 TB Store.E.TV. Attached to the PC, all the folders and files that I copied above appear. But when connecting to my TV, there is no more than all the files or folders are empty. Can please someone tell me where i

  • 9.2.1 iOS phone hangs

    Since I've updated my continuous iphone6 to break. I even have it blown out and reset Anyone else having this problem?

  • How can I play Blu - ray on my pc without a Blu - ray ripper

    I want to play Blu - ray on my Windows7 computer with a Blu - ray player from Samsung AS05, but it does not work