Need help with sql query performance

Dear all,

I have a sql like query below, I need to give the following query please help me identify which statement I should tune to have better performanece.

Select rownum LINE_NUM,

A.LINE_ID,

TO_CHAR (A.INVITMID),

TO_NUMBER (A.PICKQTY),

UNLOADINGPNT NULL,

RRNUM NULL,

WORKORDNUM NULL,

WORKORDDESC NULL,

A.PONUM,

DTR_DUMB NULL,

A.DESCRIPTION,

FROM_SUB NULL,

TO_SUB NULL,

NO SOURCE,

ASSET_NUMBER NULL,

A.RECEIPTNUM,

MOVEORD NULL,

FROM_LOC NULL,

TO_LOC NULL,

MSD_NUM NULL,

CONTAIN_LINE NULL,

A.UOM,

A.PO_RELEASE

de)

Select headerid Po.Po_Header_Id,

rcv1. Po_Line_Id LINE_ID,

rcv1.item_id INVITMID,

(NVL(Rcv1.Transact_Qty,0)-NVL(rcv2.transact_qty,0)) PICKQTY,

Po.Segment1 PONUM,

Rcv1.Receipt_Num RECEIPTNUM,

Rcv1.Item_Desc DESCRIPTION,

Rcv1.Transact_Uom GLU,

Rcv1.Po_release

Po_Headers_All in.,.

(Select rcv3. Po_Header_Id, RCV3.receipt_num, rcv3. Po_Line_Id, rcv3. Destination_Type_Code, rcv3. Item_Id, rcv3. Item_Desc, rcv3. Transact_Uom, SUM (rcv3. Transact_Qty) Transact_Qty, rcv3. PO_RELEASE OF)

SELECT A.Po_Header_Id,

C.RECEIPT_NUM receipt_num,

A.Po_Line_Id,

A.Destination_Type_Code,

B.Item_Id,

B.item_description Item_Desc,

A.UNIT_OF_MEASURE Transact_Uom,

A.QUANTITY Transact_Qty,

D.RELEASE_NUM PO_RELEASE

OF RCV_TRANSACTIONS,.

RCV_SHIPMENT_HEADERS C.

B RCV_SHIPMENT_LINES,

PO_RELEASES_ALL D

WHERE C.SHIPMENT_HEADER_ID = A.SHIPMENT_HEADER_ID

AND B.SHIPMENT_LINE_ID = A.SHIPMENT_LINE_ID

AND UPPER (A.Transaction_Type) = "to DELIVER".

AND higher (A.Destination_Type_Code) = "EXPENSES".

AND D.PO_RELEASE_ID = A.PO_RELEASE_ID

UNION ALL

SELECT A.Po_Header_Id,

C.RECEIPT_NUM receipt_num,

A.Po_Line_Id,

A.Destination_Type_Code,

B.Item_Id,

B.item_description Item_Desc,

A.UNIT_OF_MEASURE Transact_Uom,

A.QUANTITY Transact_Qty,

D.RELEASE_NUM PO_RELEASE

OF RCV_TRANSACTIONS,.

RCV_SHIPMENT_HEADERS C.

B RCV_SHIPMENT_LINES,

PO_RELEASES_ALL D

WHERE C.SHIPMENT_HEADER_ID = A.SHIPMENT_HEADER_ID

AND B.SHIPMENT_LINE_ID = A.SHIPMENT_LINE_ID

AND B.ITEM_ID IS NULL

AND UPPER (A.Transaction_Type) = "to DELIVER".

AND higher (A.Destination_Type_Code) = "WORKSHOP".

D.PO_RELEASE_ID AND = A.PO_RELEASE_ID) rcv3

GROUP BY rcv3. Po_Header_Id, RCV3.receipt_num, rcv3. Po_Line_Id, rcv3. Destination_Type_Code, rcv3. Item_Id, rcv3. Item_Desc, rcv3. Transact_Uom, rcv3. Rcv1 PO_RELEASE),

(SELECT A.PO_LINE_ID,

Sum (A.Quantity) transact_qty,

A.PO_HEADER_ID,

C.RECEIPT_NUM

OF RCV_TRANSACTIONS,.

RCV_SHIPMENT_HEADERS C.

B RCV_SHIPMENT_LINES,

PO_RELEASES_ALL D

WHERE C.SHIPMENT_HEADER_ID = A.SHIPMENT_HEADER_ID

AND B.SHIPMENT_LINE_ID = A.SHIPMENT_LINE_ID

AND UPPER (A.Transaction_Type) = "RETURN to the RECEPTION"

AND D.PO_RELEASE_ID = A.PO_RELEASE_ID

A.PO_LINE_ID, A.PO_HEADER_ID, C.RECEIPT_NUM GROUP) Rcv2

Where Po.Po_Header_Id = Rcv1.Po_Header_Id (+)

And Rcv1.Po_Line_Id = Rcv2.Po_Line_Id (+)

And Rcv1.Receipt_Num = Rcv2.Receipt_Num (+)

And Rcv1.Transact_Qty <>Nvl(Rcv2.Transact_Qty,999999999)

Group of po.po_header_id, rcv1.po_line_id, po.segment1, rcv1.receipt_num, rcv1.item_id, Rcv1.Item_Desc, rcv1. TRANSACT_UOM, rcv1. PO_RELEASE, (NVL(Rcv1.Transact_Qty,0)-NVL(RCV2.transact_qty,0))) has

Is my version of the database: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

Please find the attached PLAN to EXPLAIN.

EXPLAINPLAN.jpg

Thank you

May be essentially the same join (between a, b, c and d) twice instead of three times

sounds like it could be done with a single join (between a, b, c, and d), but you do not some columns than the columns of rcv1 rcv2

We can work on what we can see only

Select rownum line_num,

rcv1.po_line_id line_id,

TO_CHAR (rcv1.item_id) invitmid,

NVL(rcv1.transact_qty,0) - nvl(rcv2.transact_qty,0) pickqty,

unloadingpnt null,

rrnum null,

workordnum null,

workorddesc null,

Po. Ponum Segment1,

dtr_dumb null,

description of the rcv1.item_desc,

from_sub null,

to_sub null,

No source,

asset_number null,

rcv1.receipt_num receiptnum,

moveord null,

from_loc null,

to_loc null,

msd_num null,

contain_line null,

Glu rcv1.transact_uom,

rcv1.po_release

of po_headers_all in.

left outer join

(select a.po_header_id,

c.receipt_num,

a.po_line_id,

a.destination_type_code,

b.item_id,

b.item_description item_desc,

a.unit_of_measure transact_uom,

Sum (a.Quantity) transact_qty,

d.release_num po_release

from (select shipment_header_id,

shipment_line_id,

po_release_id,

po_header_id,

po_line_id,

destination_type_code,

unit_of_measure,

quantity

of rcv_transactions

where upper (a.transaction_type) = "to DELIVER".

and upper (a.destination_type_code) ('charge', 'WORKSHOP')

) a

inner join

rcv_shipment_lines b

On a.shipment_line_id = b.shipment_line_id

inner join

c rcv_shipment_headers

On a.shipment_header_id = c.shipment_header_id

left outer join

po_releases_all d

On a.po_release_id = d.po_release_id

where upper (a.destination_type_code) = "EXPENSES".

or (upper (a.destination_type_code) = 'WORKSHOP'

and b.item_id is null

)

A.po_header_id group,

c.receipt_num,

a.po_line_id,

a.destination_type_code,

b.item_id,

b.item_description,

a.unit_of_measure,

d.release_num

) rcv1

On po.po_header_id = rcv1.po_header_id

left outer join

(select a.po_line_id,

Sum (a.Quantity) transact_qty,

a.po_header_id,

c.receipt_num

from (select shipment_header_id,

shipment_line_id,

po_release_id,

po_header_id,

quantity

of rcv_transactions

where upper (a.transaction_type) = "RETURN to THE RECIPIENTS.

) a

inner join

rcv_shipment_lines b

On a.shipment_line_id = b.shipment_line_id

inner join

c rcv_shipment_headers

On a.shipment_header_id = c.shipment_header_id

left outer join

po_releases_all d

On a.po_release_id = d.po_release_id

A.po_line_id group,

a.po_header_id,

c.receipt_num

) rcv2

On rcv1.po_line_id = rcv2.po_line_id

and rcv1.receipt_num = rcv2.receipt_num

where rcv1.transact_qty! = nvl(rcv2.transact_qty,999999999)

Concerning

Etbin

Tags: Database

Similar Questions

  • need help with sql query dates

    Hello

    I have a sql query I need to extract some info between data dates. Where clause in this query is:

    WHERE CPD_BUS_UNIT =: ESI_PRM_1
    AND CPD_VOUCHER_DATE > =: P_DATE_FROM
    AND CPD_VOUCHER_DATE < (: P_DATE_TO + 1).

    When I run the query into a toad, I can view the data, but not the execution plan. It gives an error ORA-00932 inconsistent Datatypes.
    But when I remove (+ 1): P_DATE_TO, I can c the execution plan and data. The data will be different from the previous.

    Please suggest how to rewrite the query.

    Can you please give it a try?

    WHERE CPD_BUS_UNIT=:ESI_PRM_1
    AND CPD_VOUCHER_DATE >= :to_date(P_DATE_FROM)
    AND CPD_VOUCHER_DATE < (to_date(:P_DATE_TO)+1) 
    

    Concerning

  • Need help with sql query

    Dear all,

    I have a sql like query below

    SELECT min (G.TRANSACTION_DATE), D.REQUEST_NUMBER

    MTL_TXN_REQUEST_HEADERS D,.

    MTL_TXN_REQUEST_LINES, E.

    MTL_MATERIAL_TRANSACTIONS G,.

    Mtl_Transaction_Types I have

    WHERE D.HEADER_ID = E.HEADER_ID

    AND G.TRANSACTION_TYPE_ID = I.TRANSACTION_TYPE_ID

    AND Upper (I.Transaction_Type_Name) = Upper ('TEC outcome')

    AND E.LINE_ID = G.MOVE_ORDER_LINE_ID

    AND D.MOVE_ORDER_TYPE = 5

    TO_DATE (G.TRANSACTION_DATE) BETWEEN TO_DATE('01-JAN-2014') AND TO_DATE('31-DEC-2014')

    D.REQUEST_NUMBER GROUP

    I need to get the first number of the application and finally ask for number based on the date of the transaction, how can I get the number of name application and based on the date of the transaction for the same query, please help me.

    above query is back under results

    results.jpg

    If the query should return a line with the number of application like 2383 based on minimum transaction date and another column based on the maximum transaction date, please help me.

    so in the example above, it must return

    FIRST REQUEST NUMBER LAST NUMBER

    2383                                      1886

    Thank you

    select min(request_number) keep(dense_rank first order by transaction_date asc ) request_number_min
         , min(request_number) keep(dense_rank first order by transaction_date desc) request_number_max
      from (
            select min(g.transaction_date) transaction_date
                 , d.request_number
              from mtl_txn_request_headers d
                 , mtl_txn_request_lines e
                 , mtl_material_transactions g
                 , mtl_transaction_types i
             where d.header_id                    = e.header_id
               and g.transaction_type_id          = i.transaction_type_id
               and upper(i.transaction_type_name) = upper('WIP Issue')
               and e.line_id                      = g.move_order_line_id
               and d.move_order_type              = 5
               and to_date(g.transaction_date) between to_date('01-jan-2014') and to_date('31-dec-2014')
             group
                by d.request_number
           )
    
  • Need help with SQL Query - change of name history of audit table.

    I need your help to find the result in the following way...


    Emp No    New_name    Old_Name
    -----------------------------------------------
    1           Name3        Name2
    1           Name2        Name1
    create table emp(emp_id number(10),
    emp_name varchar(50),
    constraints emp_pk primary key(emp_id) );
    
    
    
    create table emp_audit(
    audit_id number(10),
    emp_id number(10),
    emp_name varchar(50),
    audit_date date,
    constraints emp_audit_pk primary key (audit_id),
    constraints  emp_audit_emp_fk foreign key(emp_id)  references emp(emp_id));
    
    insert into emp values(1,'Name3');
    
    
    insert into EMP_AUDIT (audit_id, emp_id, emp_name, audit_date)
    values (1, 1, 'Name1', to_date('14-08-2011', 'dd-mm-yyyy'));
    insert into EMP_AUDIT (audit_id, emp_id, emp_name, audit_date)
    values (2, 1, 'Name2', to_date('15-08-2011', 'dd-mm-yyyy'));
    commit;
    Thank you...

    Dipabkar Bédard (DB) wrote:

    We write is the query without using "partition by" in oracle...?

    with t as (
               select  audit_id,
                       emp_id,
                       emp_name,
                       row_number() over(order by audit_id) rn
                 from  emp_audit
                 order by emp_id,
                          audit_id
              )
    select  a.audit_id,
            a.emp_id,
            a.emp_name old_name,
            nvl(b.emp_name,(select c.emp_name from emp c where c.emp_id = a.emp_id)) new_name
      from  t a left join t b
            on (
                    b.emp_id = a.emp_id
                and
                    b.rn = a.rn + 1
               )
    /
    
      AUDIT_ID     EMP_ID OLD_NAME                                           NEW_NAME
    ---------- ---------- -------------------------------------------------- ------------
             1          1 Name1                                              Name2
             2          1 Name2                                              Name3
    
    SQL> 
    

    And without analytical functions:

    with t1 as (
                select  audit_id,
                        emp_id,
                        emp_name
                  from  emp_audit
                  order by emp_id,
                           audit_id
               ),
         t2 as (
                select  audit_id,
                        emp_id,
                        emp_name,
                        rownum rn
                  from  t1
               )
    select  a.audit_id,
            a.emp_id,
            a.emp_name old_name,
            nvl(b.emp_name,(select c.emp_name from emp c where c.emp_id = a.emp_id)) new_name
      from  t2 a left join t2 b
            on (
                    b.emp_id = a.emp_id
                and
                    b.rn = a.rn + 1
               )
    /
    
      AUDIT_ID     EMP_ID OLD_NAME                                           NEW_NAME
    ---------- ---------- -------------------------------------------------- ----------
             1          1 Name1                                              Name2
             2          1 Name2                                              Name3
    
    SQL> 
    

    SY.

  • Need help with sql query involving distinct and County

    I have 2 tables and I want to get the number of specific names. Find the details below. It's hard to explain but I will try to provide as much detail as I can.

    Table A:
    ID of the SR
    1001 1
    1002 2
    2 1003
    1004 3


    Table B:
    Name of the key SrNew
    1 David 1001
    2 James 1002
    3 James 1002
    4 James 1003
    5 James 1004
    6 Mike 1004

    Result: I'm looking:
    Count names such as if the name appears for the same ID of Table A two times, and then only count 1.

    Name of County
    David 1
    James 2 (1002 and 1003 for the same ID (ID #2) so count as 1 for this and then 1 more for 1004 and ID 3)
    1 Mike


    I have following question:
    SELECT distinct (b.Name), a.ID
    FROM TableA, TableB b
    Where a.Sr = b.SrNew Group By b.Name, a.ID

    and as a result I get:
    ID name
    David 1
    James 2
    3 James
    3 Mike


    Now, I want to just the number of each name with the result, but don't know how I can do this with a sql?

    Thanks in advance.

    Who help me?

    SELECT b.Name, count(distinct a.ID)
    FROM TableA a, TableB b
    Where a.Sr = b.SrNew
    Group By b.Name
    

    Nicolas.

  • Need help with SQL query (10 years since I have SQL)

    Hi guys,.

    I tried to remove some rust SQL. I did not go to SQL within a certain time.

    Here are the tables (% = ent $ = varcchar)
    -----------------
    RESULT
    -----------------
    % RESULT_ID-$ RC-% YEAR_ID - PERIOD_ID-% CONTRACT_NO-% value %
    20841---1439---83---37---010427102---1
    20842---1439---83---41---010427102---2
    20843---1439---84---37---010427102---3
    20844---1439---84---41---010427102---4
    20845---1439---83---34---010427102---5

    -----------------
    YEARS
    -----------------
    YEAR_ID - YEAR_DESC
    83 2010-2011
    84 2011-2012

    -----------------
    PERIOD
    -----------------
    PERIOD_ID - PERIOD_DESC
    34 14
    37 02
    41 03

    What I want is to get the last period of each year in the RESULT table. (I'll work the rest of the WHERE statement myself, because I have omitted some news, or columns for simplicity)
    Note that I can't rely on the ID of the period, as the chronological order is not respected.

    In the scenario above, I should GET
    % RESULT_ID-$ RC - YEAR_ID - PERIOD_ID-% CONTRACT_NO-% % value %
    20844---1439---84---41---010427102---4
    20845---1439---83---34---010427102---5



    I have the following, but it only returns values if the year is the last time!

    SELECT DISTINCT RESULTS. RESULT_ID, RESULT. RC, RESULT. PERIOD_ID, RESULT. YEAR_ID, RESULT. CONTRACT_NO, YEARS. YEAR_DESC
    RESULT, YEARS
    WHERE TO TRAIN. YEAR_ID = YEARS. YEAR_ID AND - it is my problem, I want the last period for each year.
    RESULT. PERIOD_ID = (SELECT PERIOD_ID FROM PERIOD WHERE CAST (PERIOD_DESC AS INT) = (Select MAX (CAST (PERIOD_DESC AS INT)) of the period)) - I think it works fine I'm able to get the last period
    ORDER BY YEARS. YEAR_DESC;

    Published by: 935079 on May 17, 2012 11:32
    Add space not formatted tabs

    Published by: 935079 on May 17, 2012 11:35

    Your way to present the data that makes it very tedious to create test data. Next time please simply provide CREATE TABLE and INSERT statements so that we can all share the same test data.

    Without test data, I think you want Frank solution with a very minor change: order value instead of id, then the number of line 1 is the highest value.

    with GOT_R_NUM as (
      SELECT r.* -- or list the columns you want
      , ROW_NUMBER() over(partition by R.YEAR_ID, R.CONTRACT_NO
        order by
    --    P.PERIOD_ID
        P.PERIOD_VALUE
        DESC NULLS LAST) AS r_num
      FROM result r
      JOIN period p ON r.period_id = p.period_id
      )
    SELECT * -- or list all columns except r_num
    FROM got_r_num
    WHERE r_num = 1;
    
  • Need help with a query result

    Oracle Version: 11.2.0.2.0

    I need assistance with the output of the query. Here is the table.

    With Tbl_Nm as

    (

    Select 'ABC1' SYSTEM_ID, REGION 'US', 'CHI' SUB_REGION 4000 BALANCE, to_date('1-JUN-2012 10:45:00 am', 'dd-mon-yyyy hh:mi:ss am') LAST_UPD_TIME, 'A' FLAG of union double all the

    Select 'PQR2', 'UK', 'LN', 2000, To_Date('1-JUL-2012 10:46:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' starting from dual Union All

    Select 'ABC1', 'IND","MAMA", 3500, To_Date('1-AUG-2012 11:47:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All

    Select "LMN3", "US", "NJ", 2500, To_Date('1-SEP-2012 09:49:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All

    Select "PQR2", "UK", "MC", 2600, To_Date('1-OCT-2012 04:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All

    Select 'ABC1', 'US', 'NY', 3200, To_Date('1-OCT-2012 06:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' starting from dual Union All

    Select "LMN3", "UK", "BT", 2400, To_Date('1-NOV-2012 07:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' From Dual

    )

    Select * from tbl_nm

    I need the output below.

    PQR2 UK MC 2600 1 OCTOBER 2012 04:45

    ABC1 US NY 3500 October 1, 2012 06:45

    LMN3 UK BT 2500 November 1, 2012 07:45

    The need the disc according to this system_id flagged as "A". But if the last disc of 'd' then it must show that the amount, but the file should be displayed in 'A '.

    I've tried a few and got stuck. Help, please. Not able to get a balance '.

    This question is a bit similar to needing help with a query result

    With Tbl_Nm as

    (

    Select 'ABC1' System_Id, region 'US', 'CHI' Sub_Region, 4000 balance, To_Date('1-JUN-2012 10:45:00 am', 'dd-mon-yyyy hh:mi:ss am') Last_Upd_Time, 'A' flag of double Union All

    Select 'PQR2', 'UK', 'LN', 2000, To_Date('1-JUL-2012 10:46:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' starting from dual Union All

    Select 'ABC1', 'IND","MAMA", 3500, To_Date('1-AUG-2012 11:47:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All

    Select "LMN3", "US", "NJ", 2500, To_Date('1-SEP-2012 09:49:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All

    Select "PQR2", "UK", "MC", 2600, To_Date('1-OCT-2012 04:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All

    Select 'ABC1', 'US', 'NY', 3200, To_Date('1-OCT-2012 06:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' starting from dual Union All

    Select "LMN3", "UK", "BT", 2400, To_Date('1-NOV-2012 07:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' From Dual

    )

    Select System_Id, region, Sub_Region, Balance, Last_Upd_Time of Tbl_Nm T1

    where t1. Last_Upd_Time = (select max (Last_Upd_Time) in the Tbl_Nm T2 where T1.) SYSTEM_ID = T2. SYSTEM_ID)

    So maybe you'd then

    ORDER BY DECODE(flag,'D',9,1) ASC...

    to get the Ds at the end of the list.

    or

    ORDER BY CASE WHAT flag = has ' (your other filters) AND then 9 or 1 end CSA,...

    HTH

  • Need help with Sql Tunning

    Under Update taking 2 h complete 3000 sets.

    UPDATE ARR_TRANSACTIONS ARR

    SET = NUMBER99

    (SELECT ARR_1.NUMBER99

    OF ARR_TRANSACTIONS ARR_1, ARR_HEADER BH

    WHERE ARR_1.ARR_ID = BH. ARR_ID

    AND BH. FLAG = "Y".

    AND ARR_1.LINE_ID = ARR. ORIG_INV_LINE_ID

    AND ARR_1.NUMBER9 IS NOT NULL

    AND ROWNUM = 1)

    WHERE ARR BATCH_ID = 26219

    AND ARR. NUMBER99 IS NULL

    I added more some condition where to reduce cost and its working fine. But I need to rise more than performance on SQL.

    Please help with SQL.

    I do not see the number of 3000 lines in the plan - so I guess that the optimizer does not compute with the correct numbers. Could generate the plan with dbms_xplan.display_cursor? This could tell us something about filter predicates and access.

    In the given situation, I would check:

    • is the access to the index in step 1 (filtered by the relevant conditions: this could be BATCH_ID = 26219) return actually 248 entries (or something similar)?
    • Access table in step 2 returning 204 lines (or something similar) after applying the filters given? If the number of lines is much bigger then a Nested Loops is perhaps not a good idea.

    To make this much simpler check, you could create a plan with statistics of content (RowSource) given that the plan containing the real and the number of estimated rows.

    If the estimated cardinalities are not plausible the next question would be if the statistics are strong and up to date.

  • Need help with SQL/PL/SQL for Dates

    Hi Experts - need help with a SQL query.

    I need to insert some date fields in a table called CALENDAR_PERIOD.

    Current data in CALENDAR_PERIOD table with their data types:

    STARTPERIOD (DATE) YEAR (NUMBER) PERIOD_LABEL (Varchar2 255)

    02/11/2014 2014 2014/02/11 SUN

    03/11/2014 2014 14/03/11 MON

    04/11/2014 2014 11/04/14 MAR

    I have to increment above values up to the year 2025. I don't know how to write SQL and increment of these values.

    Ex: My next value should insert: 05/11/2015 2014 11/05/14 WED like that I need to insert data until 12 31, 2025.

    Can you please help me with PL/SQL block?

    Really appreciate your help!

    DB version:

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

    PL/SQL Release 11.2.0.3.0 - Production

    CORE Production 11.2.0.3.0

    AMT for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production

    NLSRTL Version 11.2.0.3.0 - Production

    Thank you
    Sandy

    Hello Sandy,

    Maybe something like

    INSERT INTO calendar_period (startperiod, year, period_label)

    SELECT DATE '' 2014-11-04 + LEVEL

    , TO_NUMBER (TO_CHAR (DATE '' 2014-11-04 + LEVEL, "YYYY"))

    , TO_CHAR (DATE '' 2014-11-04 + LEVEL, "MM/DD/YY DY")

    OF the double

    CONNECT BY LEVEL<= date="" '2025-12-314="" -="" date="">

    ;

    ((mais je ne comprends pas pourquoi nous créons une telle table "année" et "period_label" peuvent être calculé à partir de startperiod))

    Best regards

    Bruno Vroman.

  • need help with the query, thx

    Hello
    I need a little help with the query I have to write;
    the table has 4 columns:
    col1               col2         col3       col4
    emp_name     empl_id    salary      year
    
    content of data:
    
    col1               col2         col3       col4
    smith             12           1200      1999
    smith             12           1340      2000
    smith             12           1500      2001
    jones             13           1550      1999 
    jones             13           1600      2000
    aron              14           1200      2002
    what I am asking is the following result: salary according to the latest available year
    i.e.
    smith         12         1500        2001
    jones         13         1600        2000
    aron          14         1200        2002
    ID appreciate some guidance on how to achieve
    Thank you
    Rgds
    select *from
    (select col1, col2,col3, col4,row_number() over(partition by col1 order by col4 desc)  rn  from 
    ) where rn=1
    
  • Help with SQL Query (Subselects)

    Hello community,

    IAM a new Member in this forum. The first excuse my English, my native language is German.
    In my workplace, we have a great Orcle Database 11 g with 30 different tables for production control issues.
    I try to get a couple of different information from the database, so I started with SQL of the query, but for this problem, I wasn't able to write a query to work.

    In this case, I have 2 tables:
    Table 1:
    ID; ORDER_NR; DESCRIPTION; CREATE_DATE
    1; A500236; CLEAN HOUSE; 20/02/2012
    2; A623555; REPAIR CAR; 10/01/2012
    3; A866944; MAINTAIN EQUIPMENT; 11/02/2012

    Table 2:
    ID; ORDER_NR; WO_STEP; STEP_DATE; EMPLOYEE
    1; A500236; A; 21/02/2012; W0010
    2; A500239; F; 21/02/2012; W0010
    3; A500239; S; 22/02/2012; W0027
    4; A500239; R; 23/02/2012; H0034
    5; A500239; U; 25/02/2012; L0099
    6; A263555; A; 15/01/2012; G0009
    7; A263555; C; 17/01/2012; S0039
    5 V A263555; R; 18/01/2012; K0059
    9; A263555; U; 19/01/2012; A0048
    10; A866944; A; 13/02/2012; H0034
    11; A866944; B; 13/02/2012; L0035
    12; A866944; G; 17/02/2012; D0084
    13; A866944; U; 23/02/2012; S0039

    And the result of my query should look like this:
    ORDER_NR; DESCRIPTION; CREATE_DATE; A_STAT_AGE; R_STAT_AGE; U_STAT_AGE
    A500236; OWN HOME; 20/02/2012; 5; 3; 1
    A623555; REPAIR CAR; 01/10/2012; 42; 39; 38
    A866944; MAINTAIN EQUIPMENT; 11/02/2012; 15; 4; 3

    The age of my query result should be calculated from the date of the creation of the order.
    I would like to know 2 things, one is how old was the order when they reached this status, R and U.
    The second, that is, how long did you order remaining on A stat, R and U (and if possible all the others too)
    It can happen that not every order reaches every State, so he ca go directly from A you in this case I want to display a generic character in this row/column

    I hope you all know what I mean and what result to expect.

    Thanks for your help.

    Reinhard W.

    Hi, Reinhard,

    990524 wrote:
    Hi Frank,.

    I thank you for your professional response and excuse my non-professional way to clarify my question.
    I have now already read and understand how to ask good questions, but is there an easy an inexpensive way to run a database on my computer at home?

    You can download the Oracle database from this site. The Express edition is easier to install. It lacks a few features that the Enterprise edition (for example, partitioning table and safety of level line), but most of the things work in all editions of Oracle.
    All editions are free if you do not use them for Production applications. Of course, at this price (or lack thereof), you get Oracle support.

    I have already noticed that the syntax SQL for Oracle differ from other DBMSS.

    Yes and some features are different in different products.

    Your query works perfectly, thank you.

    Now I want to refine my (your) query, is there a way to display a range of day within 1 day? As 0.5 day to half a day between two State timestamp.

    Of course, you can do it. After the exact output desired of the sample data that I posted. If the sample data do not show what you need to do, then after a few different examples of data that makes.

    My table contains the Date and time in a row, I forgot to mention that.

    After a CREATE TABLE statement. I was guessing a lot of things that may be important. For example, I assumed you were using a DATE for date and time column. So it is only reasonable to do so, but maybe it's not what looks like at your table.

    I tried something like this:

    SYSDATE - MIN ( CASE
                        WHEN  t2.wo_step = 'A'
                  THEN  t2.step_date
              END
               ) AS Age_A
    

    But it gives me an error of arithmetic overflow and not die difference in the Date and time or days with decimal friction.

    There are only about 5.4 million possible days with DATEs of Oracle. Is only 7 digits and Oracle can treat approximately 39 numbers without overflow errors, so I don't see how this can happen if t2.step_date is really a DATE. This is an example of why you need to publish a CREATE TABLE statement.

  • Need help with problems of performance with 14 elements

    I scanned the forums and provided below to help with feedback. At this point, the organizer of the elements is unusable for me - I'm looking for suggestions to help refine the installer to make it usable.

    MY SETUP

    • Just more than 50000 items in the catalog, about 95% of them are photos, videos of rest. 98% of the source files are on a drive to the server in my house, with a gigabit connection.
    • I left full recognition of faces (took two days!) and Yes, during that who was running the organizer was unusable.
    • My PC is an i7 - 4790 k with 16 GB of RAM. Windows Pro 10. Boot drive is SSD.

    THE SCENARIO

    I have a new series of images on my C drive local - images that I scanned, about 30 pictures. Using the view of the pane left records that I navigate to the folder on my C drive. If I move to the tab places it takes about 25 seconds to react and make enforcement appear the places page. If I then go to the people tab it takes about 75 seconds, for the application to respond. In both cases, the application is completely insensitive during the wait.

    Clearly, I can't clean my collection with this kind of response. So here are my questions:

    1. What are the key strategies to improve performance, given my configuration?
    2. Have I not too many objects in the catalog? Should I aim lower number? I saw that there is no actual limit but I feel Im beyond a theoretical limit of messages.
    3. Broken content is to catalog help with questions like this? Is there another internal setting, I should be updated or change?
    4. Given the number of images should I use Lightroom instead?

    The only change that I'm not going to do is to move all the content of my return to my local drive. Sound on the server so that it is completely backed up and protected. So I'm looking for ideas that help given this configuration.

    Thanks to everyone for their help.

    Mark

    mgill2012 wrote:

    .........

    Thanks to everyone for their help.

    Mark

    Mark,

    I can't offer a positive solution to your problem, but I hope to give you some answers or thoughts on this subject.

    Let's start with the description of your case: it's a perfect description of what has been reported in several positions:

    -powerful Installer (computer, SSD)

    -l' use of the recognition of people and/or geolocation

    -use of a NAS for the library.

    -Library of more than 50,000 points.

    -very long indexing, then extremely slow.

    I do not use a SSD (will probably later) or a NAS (I never do). I 65 000 objects and don't care about recognition of face or geolocation, which explains that with a basic setup on I3, 8 GB of RAM, I have an organizing extremely fast speed. Even on an old secondary computer with Vista, it is still quite manageable.

    Your choice is typical of advanced specialists and competent (I guess that less than 1% of the current user of items based). I have yet to see no answer (satisfactory or not...) Adobe staff.

    Given the number of images should I use Lightroom instead?

    I guess that's what Adobe could answer you... and that would be wise. You can use a trial version to make your choice and do a search on the forum for Lightroom. I have not seen similar, even if complaints with NASs, it seems to be a lot to say. Lightroom can convert your organizing catalogs (maybe some problems lately...)

    The only change that I'm not going to do is to move all the content of my return to my local drive. Sound on the server so that it is completely backed up and protected. So I'm looking for ideas that help given this configuration.

    If the use of the network is primarily to ensure maximum security (for not sharing images), why not would you use the choice to store your library on your computer (internal or external disk) with a sync to your NAS as a backup solution? I can tell you that my workflow includes Windows Synctoy to record each session easily and quickly (catalogs and libraries).

    Your very precise description of the case call to assess each factor of different performance individually. Even if the method above is not the final answer, it could shed light on the influence of the use of the network.

    1. Have I not too many objects in the catalog? Should I aim lower number? I saw that there is no actual limit but I feel Im beyond a theoretical limit of messages.
    2. Broken content is to catalog help with questions like this?

    Splitting the catalog is usually a very bad solution, a number of post seems to show that with the recognition of the people/geotagging, the problems around the range of 50,000 points. You can make a copy of the catalog and remove half of the files to check the influence of numbers point; Maybe it's possible with version 14 (deletion is extremely slow, but worked for me, even if it failed with older versions).

    Is there another internal setting, I should be updated or change?

    Sorry, I can't help you there...

    Other factors are using recognition Geotagging and people. Even if you absolutely need those features, disable to see their influence could help Adobe to solve performance issues.

  • Need help with the query. Help, please

    Hey everyone, need your help.  Thank you in advance.  In my view, there is function Pivot.  Just do not know how to use this function.  I have the query that works.  The result is:

    11-111-1111 Vlad 16505 01/04/2013 5 August 13 dental plan pre-tax amount 29,65

    11-111-1111 Vlad 16505 01/04/2013 dental pre-tax 5 August 13 Plan level EE + SP

    11-111-1111 16505 Vlad 01/04/2013 5 August 13 pre-tax Option TOP dental plan

    11-111-1111 Vlad 16505 01/04/2013 5 August 13 pre-tax dental care plan pay the value

    11-111-1111 16505 Vlad 01/04/2013 dental pre-tax 5 August 13 Plan period Type

    11-111-1111 Vlad 16505 01/04/2013 amount pre-tax medical Plan of 5 August 13 149

    11-111-1111 Vlad 16505 01/04/2013 5 August 13 pre-tax Medical Plan level EE + SP

    11-111-1111 Vlad 16505 01/04/2013 5 August 13 pre-tax Plan medical Option MED

    11-111-1111 Vlad 16505 01/04/2013 5 August 13 plan pre-tax pay value

    11-111-1111 16505 Vlad 01/04/2013 5 August 13 pre-tax Medical Plan period Type

    11-111-1111 Vlad 16505 01/04/2013 5 August 13 pre-tax Plan PPO medical Plan

    11-111-1111 Vlad 16505 01/04/2013 5 August 13 Vision Plan amount 5.94 pre-tax

    But I need the result to be

    Amount of SSN ID name item level Option PayValue period Type

    11-111-1111 Vlad 16505 01/04/2013 null null high of 5 August 13 pre-tax Dental Plan 29,65 EE + SP

    11-111-1111 Vlad 16505 01/04/2013 null null MED 5 August 13 149 medical plan pre-tax EE + SP

    11-111-1111 Vlad 16505 01/04/2013 Vision Plan before taxes of 5 August 13

    Select distinct
    ' 11-111-1111 "as ssn,
    WOMEN'S WEAR. Employee_number,
    "Vlad" as EMPLOYEE_FULL_NAME,
    TO_CHAR (papf.start_date, "MM/DD/YYYY") as Date_Of_Hire
    a.effective_start_date,
    PETF.element_name,
    pivf. Name,
    peevf.screen_entry_value

    Of
    PER_all_PEOPLE_F women's wear
    per_assignments_f A
    pay_element_types_f petf
    pay_element_links_f pelf
    PAY_ELEMENT_ENTRIES_F penf
    PAY_ELEMENT_ENTRY_VALUES_F peevf
    pay_input_values_f pivf
    WHERE
    PETF.element_name ('Dental Plan before taxes', 'Medical Plan before taxes', "Vision Plan before taxes")
    and petf. ELEMENT_TYPE_ID = pelf. ELEMENT_TYPE_ID
    and (trunc (sysdate) BETWEEN pelf. EFFECTIVE_START_DATE AND pelf. EFFECTIVE_END_DATE)
    and (pelf. ELEMENT_LINK_ID = penf. ELEMENT_LINK_ID and a.assignment_id = penf. ASSIGNMENT_ID)
    and (trunc (sysdate) BETWEEN penf. EFFECTIVE_START_DATE AND penf. EFFECTIVE_END_DATE)
    and penf. ELEMENT_ENTRY_ID = peevf. ELEMENT_ENTRY_ID
    and peevf. INPUT_VALUE_ID = pivf. INPUT_VALUE_ID
    AND papf.employee_number IS NOT NULL
    AND A.assignment_type = 'E '.
    AND A.person_id = papf.person_id
    and papf.effective_end_date > sysdate
    and a.effective_end_date > sysdate
    and (trunc (sysdate) BETWEEN women's wear. EFFECTIVE_START_DATE AND women's wear. EFFECTIVE_END_DATE)
    and a.effective_start_date = (select MAX (effective_start_date) from PER_ASSIGNMENTS_f where assignment_id = a.assignment_id)
    and a.assignment_id = 42643
    and a.assignment_status_type_id = '1'
    order of petf.element_name;

    Change with your query

    SELECT * FROM (select distinct)

    ' 11-111-1111 "as ssn,

    WOMEN'S WEAR. Employee_number,

    "Vlad" as employee_full_name,

    TO_CHAR (papf.start_date, "MM/DD/YYYY") as date_of_hire

    a.effective_start_date,

    PETF.element_name,

    pivf. Name,

    peevf.screen_entry_value

    Of

    PER_all_PEOPLE_F women's wear

    per_assignments_f A

    pay_element_types_f petf

    pay_element_links_f pelf

    PAY_ELEMENT_ENTRIES_F penf

    PAY_ELEMENT_ENTRY_VALUES_F peevf

    pay_input_values_f pivf

    WHERE

    PETF.element_name ('Dental Plan before taxes', 'Medical Plan before taxes', "Vision Plan before taxes")

    and petf. ELEMENT_TYPE_ID = pelf. ELEMENT_TYPE_ID

    and (trunc (sysdate) BETWEEN pelf. EFFECTIVE_START_DATE AND pelf. EFFECTIVE_END_DATE)

    and (pelf. ELEMENT_LINK_ID = penf. ELEMENT_LINK_ID and a.assignment_id = penf. ASSIGNMENT_ID)

    and (trunc (sysdate) BETWEEN penf. EFFECTIVE_START_DATE AND penf. EFFECTIVE_END_DATE)

    and penf. ELEMENT_ENTRY_ID = peevf. ELEMENT_ENTRY_ID

    and peevf. INPUT_VALUE_ID = pivf. INPUT_VALUE_ID

    AND papf.employee_number IS NOT NULL

    AND A.assignment_type = 'E '.

    AND A.person_id = papf.person_id

    and papf.effective_end_date > sysdate

    and a.effective_end_date > sysdate

    and (trunc (sysdate) BETWEEN women's wear. EFFECTIVE_START_DATE AND women's wear. EFFECTIVE_END_DATE)

    and a.effective_start_date = (select MAX (effective_start_date) from PER_ASSIGNMENTS_f where assignment_id = a.assignment_id)

    and a.assignment_id = 42643

    and a.assignment_status_type_id = '1')

    PIVOT (MAX (screen_entry_value) FOR (name) TO ("Amount" AS 'Amount', 'level' AS 'level', 'Option High' AS 'High Option', 'Pay the value' AS 'Value to pay', 'Period of Type' AS 'Type period'))

    order by element_name;

    (GOLD)

    SELECT ssn,

    Employee_number,

    employee_full_name,

    date_of_hire,

    effective_start_date,

    element_name,

    Max (decode (Name, 'Amount', screen_entry_value)) 'amount. "

    Max (decode (Name, 'Level', screen_entry_value)) 'level ',.

    MAX (DECODE (name, "High Option", screen_entry_value)) "High Option",

    MAX (DECODE (name, 'Value of pay', screen_entry_value)) 'value of pay. "

    MAX (DECODE (name, 'Period Type', screen_entry_value)) 'period of Type '.

    FROM (select distinct)

    ' 11-111-1111 "as ssn,

    WOMEN'S WEAR. Employee_number,

    "Vlad" as employee_full_name,

    TO_CHAR (papf.start_date, "MM/DD/YYYY") as date_of_hire

    a.effective_start_date,

    PETF.element_name,

    pivf. Name,

    peevf.screen_entry_value

    Of

    PER_all_PEOPLE_F women's wear

    per_assignments_f A

    pay_element_types_f petf

    pay_element_links_f pelf

    PAY_ELEMENT_ENTRIES_F penf

    PAY_ELEMENT_ENTRY_VALUES_F peevf

    pay_input_values_f pivf

    WHERE

    PETF.element_name ('Dental Plan before taxes', 'Medical Plan before taxes', "Vision Plan before taxes")

    and petf. ELEMENT_TYPE_ID = pelf. ELEMENT_TYPE_ID

    and (trunc (sysdate) BETWEEN pelf. EFFECTIVE_START_DATE AND pelf. EFFECTIVE_END_DATE)

    and (pelf. ELEMENT_LINK_ID = penf. ELEMENT_LINK_ID and a.assignment_id = penf. ASSIGNMENT_ID)

    and (trunc (sysdate) BETWEEN penf. EFFECTIVE_START_DATE AND penf. EFFECTIVE_END_DATE)

    and penf. ELEMENT_ENTRY_ID = peevf. ELEMENT_ENTRY_ID

    and peevf. INPUT_VALUE_ID = pivf. INPUT_VALUE_ID

    AND papf.employee_number IS NOT NULL

    AND A.assignment_type = 'E '.

    AND A.person_id = papf.person_id

    and papf.effective_end_date > sysdate

    and a.effective_end_date > sysdate

    and (trunc (sysdate) BETWEEN women's wear. EFFECTIVE_START_DATE AND women's wear. EFFECTIVE_END_DATE)

    and a.effective_start_date = (select MAX (effective_start_date) from PER_ASSIGNMENTS_f where assignment_id = a.assignment_id)

    and a.assignment_id = 42643

    and a.assignment_status_type_id = '1')

    GROUP BY ssn, employee_number, employee_full_name, date_of_hire, effective_start_date, NOM_ELEMENT

    order by element_name;

  • Need help with SQL SELECT

    Hello

    I have a table named WORK_CODES
    There only a single column CODE
    The CODE values are
    YES
    NO.
    A
    B
    C

    I get a connection variable: var1
    If: var1 is TRUE = > YES, I'll be back
    If: var1 is NOT TRUE = > I would alternate record in the WORK_CODES table.

    The tricky part is that it must be managed in a SQL query.
    Any help on this is appreciated.

    Thank you
    Pradeep


    The first problem I see is that SQL does not support the Boolean data type. Then you must consider changing the data type of your variable binding.

    Assuming that you change it to integer where 1 = 0 = false and true, you can do

    I guess I misunderstood. You can do it simply.

    select *
      from 
     where (:var = 'TRUE' and code = 'YES') or (:var = 'NOT TRUE' and code != 'YES')
    

    Published by: Karthick_Arp on January 14, 2010 23:30

  • Help with sql query / a subquery to perform the COUNT

    Hello everyone,

    Co-worker colleague asked me to post a request here in hopes of getting more support.  Here's the question:

    There are 3 tables associated with this request.  A table of the application, which displays a number of application open for a particular request, an audit table that shows you all employees who worked on this application and one employee who shows you the details of the employee table.  My colleague is trying to understand what, how to see only applications that have been published by a wizard, but not a Manager.  There are a few applications that worked on both, but he won't see this request in its results.

    Here are the tables

    EMP

    ID FULL_NAME
    1234John Doe
    5467Jane Doe
    2345Clark Kent
    5432June Cleaver

    Unfortunately, this table does not have a title column (which was created provider, so we cannot change the internal structure).  My colleague knows who is the Assistant and the Director, then in this case, the first two of the id:

    1234 and 5467 are managers and the other 2 are assistants

    T_APPLICATION

    app_id app_number date_opened app_type
    901854778JANUARY 10, 2014NETWORK
    901954779JANUARY 11, 2014DATABASE
    901055000MARCH 12, 2014MATERIAL

    T_APP_AUDIT

    APP_ID PROCESSED_BY
    90181234
    90182345
    90185432
    90192345
    90195432
    90105432

    So, here is the actual query, I was given: it is actually to check the number of times that each application has been published per person:

    Select a.app_id, c.full_name, count (*) that controls

    t_application a, t_app_audit b, c of the emp

    where a.app_id = b.app_id and b.processed_by = c.id and

    a.app_type in ('NETWORK', "DATABASE")

    and b.processed not in ('1234, ' 5467')

    GROUP OF A.APP_ID, c.full_name;

    IF I won't see 9018 in my results, since at one time it was edited by a Manager (1234).  Unfortunately, this request does not eliminate the app_id 9018, it eliminates only the name of handlers appear in the query.  I hope I've explained this properly, and any help to point us in the right direction is welcomed.  Thanks in advance.

    Select

    a.app_id

    c.full_name

    , count (*) as the controls

    of t_application one

    t_app_audit b

    c of the emp

    where a.app_id = b.app_id

    and b.processed_by = c.id

    and a.app_type in ('NETWORK', "DATABASE")

    and b.app_id by (not in

    Select app_id

    of t_app_audit

    where processed_by in ('1234, ' 5467')

    )

    GROUP OF A.APP_ID, c.full_name;

Maybe you are looking for