Sub query with order of

Hello


I created a sub with sorting on a column request. (I have cutomized the IKM control append for order). I see the order by the State. If I use this (interface yellow) subquery in the main query (is also yellow interface) I do not see the order of condition


Subquery (Q-yellow interface):

Select

NEST,
START_TIME,
ACTION_TYPE_CODE


Of

(




SELECT DISTINCT
SERVICE_TRACKING_S.PID PID,
START_TIME TO_TIMESTAMP (TO_CHAR (SERVICE_TRACKING_S.ACTION_TIME, 'DD-MON-YY HH24:MI:SS'), "MON-DD-YY HH24:MI:SS"),
SERVICE_TRACKING_S.ACTION_TYPE_CODE ACTION_TYPE_CODE
of KSTGDB. SERVICE_TRACKING_S SERVICE_TRACKING_S

where (1 = 1)

ORDER BY-----------------------------------------------
NEST
START_TIME CSA


)

ODI_GET_FROM

Main query (Q1 - yellow interface):

Select
NEST,
START_TIME,
ACTION_TYPE_CODE,
RN,
RN_MAX

CEN


Select
Q.PID PID,
Q.START_TIME START_TIME,
WHEN Q.START_TIME - LAG(Q.START_TIME,1,Q.START_TIME) CASE above (PARTITION OF Q. PID ORDER OF Q.START_TIME) > numtodsinterval(75,'minute')
or Q.PID! = LAG (Q.PID, 1, 0) ON (Q.PID ORDER OF Q.START_TIME PARTITION) THEN 1 OTHER Q.ACTION_TYPE_CODE END ACTION_TYPE_CODE.
ROW_NUMBER() OVER(PARTITION BY Q.PID ORDER BY Q.START_TIME) RN,
Count (*) over (PARTITION OF Q.PID ORDER OF Q.START_TIME LINES BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
RN_MAX
de)

SELECT DISTINCT
SERVICE_TRACKING_S.PID PID, START_TIME TO_TIMESTAMP (TO_CHAR (SERVICE_TRACKING_S.ACTION_TIME, 'DD-MON-YY HH24:MI:SS'), "MON-DD-YY HH24:MI:SS"), SERVICE_TRACKING_S.ACTION_TYPE_CODE ACTION_TYPE_CODE
of KSTGDB. SERVICE_TRACKING_S SERVICE_TRACKING_S
where (1 = 1)

-I don't get stopped by here-
) Q
where (1 = 1)
) ODI_GET_FROM

Thanks in advance

K

Hello

what you trying to do? A decree by a subselect in the useless statement.

Also use an order you need to add an option and change the IKM

Tags: Business Intelligence

Similar Questions

  • Order By in the Sub query

    We cannot use ORDER BY in the Sub query.
    select * from emp where emp_no in (select emp_id from dept order by dept_no )
    Get the below error
    ORA-00907: missing right parenthesis

    Hello

    user13024762 wrote:
    To get the number of EMP table for maximum number of dept dept

    If this is what you want, then do something like this:

    select  *
    from      emp
    where      emp_no in (
                          select    MAX (emp_no) KEEP (DENSE_RANK LAST ORDER BY dept_no NULLS FIRST)
                   from      dept
                )
    ;
    

    or maybe

    select  *
    from      emp
    where      emp_no  = (
                          select    emp_no
                   from      dept
                   where     dept_no = (
                                                    SELECT  MAX (dept_no)
                                 FROM    dept
                                                 )
                )
    ;
    

    Depending on what you want in the case of a tie.

    select * from emp where emp_no in (select emp_no from dept where rownum =1 order by dept_no desc)
    

    The subquery that you posted above does not necessarily return the line containing the largest dept_no, since ROWNUM is affected before ORDER BY is done.

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all tables and also post the results desired from these data.
    Explain how you get these results from these data.

  • Problems with Sub query

    Hello, I'm looking to create a sub query to display certain information. On the form that the information is entered, the user has the option to enter a phone number extension, as appropriate. If this is the case, I want the phone number to show as 555-867-5309 (x 1234). However, without the problem of controls, the (x) will be displayed without worrying and seems sloppy. Here is the code I have, please notify.

    There will be two places, it will be necessary - for the telephone number of the applicant and the app (SME) contact information manager.

    Thank you.

    select
        pm.pk_proj_master_id "Project Number",
        pm.trackit_work_order "TrackIt Work Order",
        pm.name "Project Name",
        pm.status "Project Status",
        req.last_name||', '||req.first_name||', '||req.middle_initial||'.' "Requestor Name",
        rde.department_group_descr "Requestor Department Name",
        req.department_descr "Requestor Division Name",
        
        pm.requester_ext,
        case
            when pm.requester_ext in 
                (
                select 
                    pm.requester_phone|| '(x'||pm.requester_ext ||')' "Requesters Number"
                from 
                    protrac_master pm
                where
                    pm.requester_ext is not null
                )
            
            else
                (
                select
                    pm.requester_phone "Requesters Number"
                from 
                    protrac_master pm
                )   
        end as "Requester Number",
         
        man.last_name||', '||man.first_name||', '||man.middle_initial||'.' "SME Name",
        mdg.department_group_descr "SME Department Name",
        man.department_descr "SME Division Name",
        
        pm.app_manager_ext,
        case
            when pm.app_manager_ext in 
                (
                select 
                    pm.app_manager_phone|| '(x'||pm.app_manager_ext ||')' "SME Number"
                from 
                    protrac_master pm
                where
                    pm.app_manager_phone is not null
                )
            
            else
                (
                select
                    pm.app_manager_phone "SME Number"
                from 
                    protrac_master pm
                )   
        end as "Requester Number",
    
        pm.createby_date "Date Entered",
        pm.date_begin "Date Began",
        pm.date_completed "Date Completed",
        pm.estimated_date "Estimated Completion Date"
    
    from
        protrac_master pm,
        cobr.vw_pps_payroll req, cobr.department_group rde,
        cobr.vw_pps_payroll man, cobr.department_group mdg
        
    where
        pm.requester_id         = req.emple_no and
        pm.requester_dept_id    = rde.pk_department_group_id and
        pm.app_manager_id       = man.emple_no and 
        pm.app_manager_dept_id  = mdg.pk_department_group_id
        
    order by 
        pm.pk_proj_master_id

    I think you can avoid the sub query thing simply by using the NVL2 function:

    select ...
         , NVL2( pm.requester_ext
               , pm.requester_phone|| '(x'||pm.requester_ext ||')'
               , pm.requester_phone) "Requesters Number"
           ...
         , NVL2( pm.app_manager_ext
               , pm.app_manager_phone|| '(x'||pm.app_manager_ext ||')'
               , pm.app_manager_phone) "Manager Number"
           ...
      from protrac_master pm
         , ...
    
  • Write a SQL query with lines in columns

    All the

    I need help in writing a SQL query with lines in columns, let give u an example...

    drop table activity;

    CREATE TABLE 'ACTIVITY '.

    (

    "PROJECT_WID" NUMBER (22.0) NOT NULL,

    VARCHAR2 (150 CHAR) "PROJECT_NO."

    VARCHAR2 (800 CHAR) 'NAME '.

    );

    Insert in the ACTIVITY (PROJECT_WID, PROJECT_NO, NAME) values (1683691, '10007', 12-121');

    Insert in the ACTIVITY (PROJECT_WID, PROJECT_NO, NAME) values (1684994, '10008', 12-122');

    Insert in the ACTIVITY (PROJECT_WID, PROJECT_NO, NAME) values (1686296, '10009', 12-123');

    Insert in the ACTIVITY (PROJECT_WID, PROJECT_NO, NAME) values (2225222, '9040', 12-124');

    drop table lonet;

    CREATE TABLE 'LONET.

    (

    VARCHAR2 (150 CHAR) "NAME."

    NUMBER OF THE "ROOT."

    VARCHAR2 (150 CHAR) "ENTRYVALUE".

    );

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ("GAC", 1683691, "LDE");

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('NAM', 1683691, 'LME');

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('BAG', 1683691, 'ICE');

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('PAP', 1683691, 'IKE');

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('NAM', 1686291, "QTY");

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('PAP', 1686291, 'MAX');

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ("GAC", 1684994, "MTE");

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('PAP', 1684994, 'MAC');

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('FMT', 1684994, 'NICE');

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('FMR', 1684994, 'RAY');

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('BAG', 1686296, "CAQ");

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ("PAP", 1686296, "QAQ");

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ("VANESSA", 1686296, "THEW");

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ("ANDR", 1686296, "REYL");

    commit;

    Link: activity.project_wid = lonet.root

    look like output

    Project_wid Project_no NAME GAC NAM BAG RAC
    16836911000712-121LDELMELCELKE
    16849941000812-122MTEnullnullMAC
    16862961000912-123nullnullCAQQAQ
    2225222904012-124nullnullnullnull

    two problems, in that I am running

    1. I dono how simply we can convert rows to columns

    2. for root = 1683691, there are double NAM and RAC in lonet table... ideally these data should not be there, but since its here, we can take a MAX so that it returns a value

    3. There are undesirables who should be ignored

    Once again my thought process is that we join the activity and 4 alias table lonet.

    ask for your help in this

    Thank you

    Hello

    This is called pivoting.

    Here's a way to do it:

    WITH relevant_data AS

    (

    SELECT a.project_wid, a.project_no, b.SID

    , l.name AS lonet_name, l.entryvalue

    Activity one

    LEFT OUTER JOIN lonet l.root = a.project_wid l

    )

    SELECT *.

    OF relevant_data

    PIVOT (MAX (entryvalue)

    FOR lonet_name IN ("GAC" IN the gac

    "NAM" AS nam

    'BAG' IN the bag

    "RAC" AS cars

    )

    )

    ORDER BY project_wid

    ;

    Output:

    PROJECT_WID PROJECT_NO GAC NAM BAG RAC NAME

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

    1683691 12 - 10007 121 LDE LME LCE LKE

    1684994 MAC MTE 10008 12-122

    1686296 12 - 10009 123 QAC QAQ

    2225222 9040 12 - 124

    To learn more about swivel, see the FAQ in the Forum: Re: 4. How can I convert rows to columns?

    Thanks for posting the CREATE TABLE and INSERT statements; It's very useful!

  • DISTINCT with ORDER BY

    All,

    Facing a problem with the query below... "DISTINCT with Order By Clause.

    His work when we take the same distinct column and order at this time where the query works. But in my case... There are a couple of b/w of joining tables... and are distinct for a column and the order is for a different table with a different column.

    Please suggest me a solution for this below query column in the separate and column used for sorting are different.

    SELECT DISTINCT gl_cc.segment2

    OF gl_code_combinations gl_cc,.

    per_all_people_f req_emp,

    per_all_assignments_f req_emp_assign

    WHERE req_emp.person_id = req_emp_assign.person_id

    AND gl_cc.code_combination_id =

    req_emp_assign.default_code_comb_id

    AND req_emp.full_name = 'xyz '.

    ORDER BY req_emp_assign.last_update_date DESC

    Thank you

    Problem will takes us to Basic!

    Processing order for SELECT statements.

    SQL query(Non recursive SQL) are processed in the following order

    FROM clause

    WHERE clause

    GROUP BY clause

    HAVING clause

    SELECT clause

    ORDER BY clause

    So if you have something in the ORDER BY, but even not Fetch in SELECT it is bound to view the error.

    Given THAT order will work on column projected by SELECT!

    Single table query will fail also.

    Select distinct ename in order by empno emp;

    SQL error: ORA-01791: not a selected expression

    01791 00000 - "not a selected expression.

    * Cause:

    * Action:

    Inclusion of the req_emp_assign.last_update_date in the select column is necessary for order processing

  • using rownum with order by

    Hi all

    I want to use rownum with order of clause-

    When I use an order clause in the select query, I get so many lines that I don't want.
    I have average-i want only two first rows according to the order of.

    EG. - Select employee_id, salary of the order of salary employees;
    EMPLOYEE_ID, FIRST_NAME SALARY
    ----------- -------------------- --------
    132 2100 TJ
    Steven 128 2200
    2200 hazelnut 136
    James 127 2400
    135 Ki 2400

    now, I just want to see the first two lines of the output above.
    any oneone please help does
    SQL> SELECT *
    FROM   (SELECT employee_id,
                   first_name,
                   salary
            FROM   employees
            ORDER  BY salary)
    WHERE  ROWNUM < 3;   2    3    4    5    6    7  
    
    EMPLOYEE_ID FIRST_NAME               SALARY
    ----------- -------------------- ----------
            132 TJ                         2100
            128 Steven                     2200
    
  • Problem with order by clause

    Hai all,

    I have problem with order by clause,

    My query is

    "Select number from table1 order number CSA.

    and the output as

    1
    10
    12
    13
    15
    17
    19
    2
    20
    21
    22
    .
    ........

    But if we give the order that it should display below the only good?

    1
    2
    10
    12
    13
    15
    17
    19
    20
    21
    22 ........

    Help me please why it is not displayed as she. and how to make the statement to display as in the second case. Thanks in advance.

    Kind regards
    Uraja

    In your table, the column is VARCHAR2 data type.

    It is a string, even if it is to store numeric values, it will get condemn as strings

    Try the below

    select your_column from table1 order by to_number(your_column) asc 
    

    Published by: JAC on November 19, 2012 16:35

  • SQL query with the troubleshooting Subselects

    I have a query with the 3 Subselects. Each of the Subselects works very well on its own. I run the query in Oracle SQL Developer and get ORA 933 "sql command not completed successfully" at 47 48 line pass. I am unable to say what is causing the error. The pointers you know sincerely!

    Here is the code:
    SELECT 
      adjud.country,
      adjud.site,
      adjud.prodtype,
      sum(adjud.acount) + sum(denied.dcount) as TotalClosed,
      case when adjud.adtype = 'Paid' then adjud.acount End as NumPaid,
      case when adjud.adtype = 'Paid' then adjud.totalpaid End as AmtPaid,
      count(adjud.contest) + count(denied.contest) + count(pend.contest) as CntContestable,
      sum(pend.pcount) as PendingCount,
      Case when pend.overunder = 'Over' Then count(pend.pcount) End as Over90Count,
      sum(pend.facevalue) as PendingAmount
    From 
    ( select 
        count(clm.clm_nbr) as acount, 
        sum(clm.rsrv_amt) as facevalue,
        sum(clm.tot_pd_amt) as totalpaid,
        clm.prdt_type_nm as prodtype,
        clm.cntsbl_indc as contest,
        case when clm.exam_co_cd in ('107','134')
          then 'Hong Kong'
          else 
            case when clm.exam_co_cd = '234'
              then 'Singapore'
              else 'US'
            End
        End as country,
        clm.exam_admin_site_cd as site,
        Case when clm.rmk_cd in ('R00', 'R01', 'R02') then 'Denied' Else 'Paid' End as adtype
      from afp_cds.claim_vw clm
      where 
        clm.adjud_dt is not null and 
        clm.adjud_dt > :startDate and
        clm.adjud_dt < :EndDate
      group by 
        clm.prdt_type_nm,
        clm.cntsbl_indc,
        case when clm.exam_co_cd in ('107','134') 
          then 'Hong Kong'
          else 
            case when clm.exam_co_cd = '234'
              then 'Singapore'
              else 'US'
            End
        End,
        clm.exam_admin_site_cd,
        Case when clm.rmk_cd in ('R00', 'R01', 'R02') then 'Denied' Else 'Paid' End
    ) as adjud, 
    ( select 
        count(clm.clm_nbr) as dcount,
        sum(clm.rsrv_amt) as facevalue,
        clm.prdt_type_nm as prodtype,
        case when clm.exam_co_cd in ('107','134') 
          then 'Hong Kong'
          else 
            case when clm.exam_co_cd = '234'
              then 'Singapore'
              else 'US'
            End
        End as country,
        clm.exam_admin_site_cd as site,
        clm.cntsbl_indc as contest
      from afp_cds.claim_vw clm
      where 
        clm.deny_dt is not null and
        clm.deny_dt > :startDate and
        clm.deny_dt < :EndDate
      group by
        clm.prdt_type_nm,
        case when clm.exam_co_cd in ('107','134') 
          then 'Hong Kong'
          else 
            case when clm.exam_co_cd = '234'
              then 'Singapore'
              else 'US'
            End
        End,
        clm.exam_admin_site_cd,
        clm.cntsbl_indc
    ) as denied,
    ( select 
        count(clm.clm_nbr) as pcount, 
        sum(clm.rsrv_amt) as facevalue,
        clm.prdt_type_nm as prodtype,
        case when clm.exam_co_cd in ('107','134') 
          then 'Hong Kong'
          else 
            case when clm.exam_co_cd = '234'
              then 'Singapore'
              else 'US'
            End
        End as country,
        clm.exam_admin_site_cd as site,
        clm.cntsbl_indc as contest,  
        case when sysdate - clm.regtrtn_dt > 90 then 'Over' else 'Under' End as overunder
      from afp_cds.claim_vw clm
      where
        clm.adjud_dt is null and
        clm.deny_dt is null
      group by
        clm.prdt_type_nm,
        case when clm.exam_co_cd in ('107','134') 
          then 'Hong Kong'
          else 
            case when clm.exam_co_cd = '234'
              then 'Singapore'
              else 'US'
            End
        End,
        clm.exam_admin_site_cd,
        clm.cntsbl_indc,  
        case when sysdate - regtrtn_dt > 90 then 'Over' else 'Under' End
    ) as pend
    
    where
      adjud.prodtype = denied.prodtype and
      adjud.country = denied.country and
      adjud.site = denied.site and
      adjud.contest = denied.contest and
      adjud.prodtype = pend.prodtype and
      adjud.country = pend.country and
      adjud.site = pend.site and
      adjud.contest = pend.contest 
    group by
      adjud.country,
      adjud.site,
      adjud.prodtype,
      case when adjud.adtype = 'Paid' then adjud.acount End,
      case when adjud.adtype = 'Paid' then adjud.totalpaid End,
      Case when pend.overunder = 'Over' Then count(pend.pcount) End

    Do not use "Sub" with the table alias.

    Change this stmt type:

    ) as adjud,
    

    TO

    ) adjud,
    
  • Separate option is not allowed with Order By.

    Hi all
    I use a parameter in a query for a report like this:

    Select Name, Id
    of employees, emp_orders
    where employees.id = emp_orders.id - table employees is the master
    and (: order_type_id is null or)
    ((: order_type_id = emp_orders.order_type_id)) -: order_type_id is the user setting
    order of employees.seq_no

    the above query runs successfully but it doubles the data for employees with more than one order, if it has two orders, as it returns records for same twice and if it is of three that it returns the same records for three times!
    I tried to fix it by putting the Distinct after select Word option, but in this case, it gives me this error:
    ORA-01791: not a SELECTed expression

    and when I remove the order by expression data duplication is gone like wanted!

    How to solve the problem please? Thank you
    Note: I use Oracle reports 6i

    http://ORA-01791.ora-code.com/

    Separate option is not allowed with Order By.

    Why

    SQL> with t as
      2  (
      3    select 1 id, 'str' str from dual union all
      4    select 2 id, 'str' str from dual union all
      5    select 1 id, 'str' str from dual
      6  )
      7  select id, str from t
      8  order by id, str
      9  /
    
            ID STR
    ---------- ---
             1 str
             1 str
             2 str
    
    SQL>
    SQL> with t as
      2  (
      3    select 1 id, 'str' str from dual union all
      4    select 2 id, 'str' str from dual union all
      5    select 1 id, 'str' str from dual
      6  )
      7  select distinct id, str from t
      8  order by id, str
      9  /
    
            ID STR
    ---------- ---
             1 str
             2 str
    
    SQL> 
    

    You can try to group by

    SQL> with t as
      2  (
      3    select 1 id, 'str' str from dual union all
      4    select 2 id, 'str' str from dual union all
      5    select 1 id, 'str' str from dual
      6  )
      7  select id, str from t
      8  group by id, str
      9  order by id, str
     10  /
    
            ID STR
    ---------- ---
             1 str
             2 str
    
    SQL> 
    
  • SQL query with dynamic exercise

    Hello

    I wrote this query with static exercise and exercise, I need info on making the dynamic variables

    Exercise: starts from July1st. This year up to June 30 is "2011" and July ' 1's '2012'
    Exercise: July1st his '1' and June ' 1 his '12'

    Query:

    Select distinct o.c_num, o.ac_num, s.sub_ac_num, o.fiscal_year, o.ac_exp_date, s.sub_ac_ind
    of org_account o
    outer join left sub_account s
    on o.c_num = s.c_num and o.ac_num = s.ac_num
    where (o.ac_exp_date > = CURRENT_DATE or o.ac_exp_date is null)
    and o.fiscal_year = * '2011' * -> need to be dynamic
    and o.fiscal_period = * '12' * -> need to be dynamic

    Thank you
    Mano

    Published by: user9332645 on June 2, 2011 18:55

    Hi, Mano,

    Welcome to the forum!

    Whenever you have a question, please post a small example of data (CREATE TABLE and INSERT statements) and the results desired from these data.
    Always tell what version of Oracle you are using.

    Since this is your first thread, I will post some examples of data for you:

    CREATE TABLE     table_x
    (     dt     DATE
    );
    
    INSERT INTO table_x (dt) VALUES (DATE '2010-12-31');
    INSERT INTO table_x (dt) VALUES (DATE '2011-01-01');
    INSERT INTO table_x (dt) VALUES (DATE '2011-06-02');
    INSERT INTO table_x (dt) VALUES (DATE '2011-06-30');
    INSERT INTO table_x (dt) VALUES (DATE '2011-07-01');
    

    What is the output you can from these data?

    DT          FISCAL_YEAR     FISCAL_PERIOD
    ----------- --------------- ---------------
    31-Dec-2010 2011            06
    01-Jan-2011 2011            07
    02-Jun-2011 2011            12
    30-Jun-2011 2011            12
    01-Jul-2011 2012            01
    

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

    SELECT       dt
    ,       TO_CHAR ( ADD_MONTHS (dt, 6)
                , 'YYYY'
                )     AS fiscal_year
    ,       TO_CHAR ( ADD_MONTHS (dt, 6)
                , 'MM'
                )     AS fiscal_period
    FROM       table_x
    ORDER BY  dt
    ;
    

    Since your exercise begins 6 months prior to the calendar year, you must add 6 months to the actual date for the fiscal year and month.

    The above query produces strings for fiscal_year and fiscal_period. If you prefer to have the numbers, then use EXTRACT instead of TO_CHAR:

    SELECT       dt
    ,       EXTRACT (      YEAR
                FROM     ADD_MONTHS (dt, 6)
                )     AS fiscal_year
    ,       EXTRACT (      MONTH
                FROM     ADD_MONTHS (dt, 6)
                )     AS fiscal_period
    FROM       table_x
    ORDER BY  dt
    ;
    

    The first query will work in Oracle 6 (and more).
    I don't know when EXTRACT was introduced. Certainly, it works in Oracle 10 and may be available in older versions too.

  • How to know what sub query returns multiple rows

    Hi all

    Someone can give me hints, how to know what sub query returns many rows in the following query.
    /* Formatted on 2011/05/17 19:22 (Formatter Plus v4.8.8) */
    SELECT a.*, ROWNUM AS rnm
      FROM (SELECT DISTINCT '1' AS "Page View", ou.org_unit_name AS "Org",
                            prxm.mbr_idntfr AS "Beneficiary ID",
                               md.last_name
                            || ', '
                            || md.first_name AS "Beneficiary Name",
                            pci.idntfr AS "Tracking No.",
                            TO_CHAR (TRUNC (req.pa_rqst_date),
                                     'MM/dd/yyyy'
                                    ) AS "Request Date",
                            sts.status_name AS "Status",
                            req.pa_rqst_sid AS "Request #",
                            prxm.mbr_sid AS "Mbr_sid",
                            TO_CHAR
                                  (TRUNC (req.pa_revision_date),
                                   'MM/dd/yyyy'
                                  ) AS "Last Updated",
                            TO_CHAR (psd.TO_DATE, 'MM/dd/yyyy') AS "TO_DATE",
                            prxpl.prvdr_lctn_iid AS "PRVDR_LCTN_IID",
                            pd.prvdr_sid AS "PRVDR_SID", 'Y' AS "State View",
                            DECODE
                               ((SELECT DISTINCT pd.national_prvdr_idntfr
                                            FROM pa_request_x_provider_location prxplo
                                           WHERE prxplo.pa_rqst_sid =
                                                                   req.pa_rqst_sid
                                             AND prxplo.oprtnl_flag = 'A'
                                             AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
                                0, (SELECT prxplo.prvdr_lctn_idntfr
                                      FROM pa_request_x_provider_location prxplo
                                     WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
                                       AND prxplo.oprtnl_flag = 'A'
                                       AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
                                NULL, (SELECT prxplo.prvdr_lctn_idntfr
                                         FROM pa_request_x_provider_location prxplo
                                        WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
                                          AND prxplo.oprtnl_flag = 'A'
                                          AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
                                (SELECT DISTINCT pd.national_prvdr_idntfr
                                            FROM pa_request_x_provider_location prxplo
                                           WHERE prxplo.pa_rqst_sid =
                                                                   req.pa_rqst_sid
                                             AND prxplo.oprtnl_flag = 'A'
                                             AND prxplo.pa_prvdr_type_lkpcd = 'RR')
                               ) AS "NPI/ID",
                            DECODE
                               ((SELECT pd.org_bsns_name
                                   FROM pa_request_x_provider_location prxplo
                                  WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
                                    AND prxplo.oprtnl_flag = 'A'
                                    AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
                                NULL, (SELECT    pd.last_name
                                              || ', '
                                              || pd.first_name
                                              || ' '
                                              || pd.middle_name
                                         FROM pa_request_x_provider_location prxplo
                                        WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
                                          AND prxplo.oprtnl_flag = 'A'
                                          AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
                                (SELECT pd.org_bsns_name
                                   FROM pa_request_x_provider_location prxplo
                                  WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
                                    AND prxplo.oprtnl_flag = 'A'
                                    AND prxplo.pa_prvdr_type_lkpcd = 'RR')
                               ) AS "Prvdr Name",
                            TO_CHAR (psd.from_date,
                                     'MM/dd/yyyy'
                                    ) AS "Srvc From Date",
                            TO_CHAR (req.validity_start_date,
                                     'MM/DD/YYYY'
                                    ) AS "Due Date",
                            (fn_get_busniess_days (TRUNC (req.validity_start_date))
                            ) AS "Days<br>Left",
                            req.pa_mode_type_lkpcd AS "Source",
                            TO_CHAR (TRUNC (wmdtl.rtng_date),
                                     'MM/dd/yyyy'
                                    ) AS "Assigned On",
                            NVL (wmdtl.assigned_to_user_name,
                                 'Not Assigned'
                                ) AS "Assigned To",
                            req.org_unit_sid AS "OrgUnitSid",
                            TO_CHAR
                                 (wmdtl.modified_date,
                                  'MM/dd/yyyy hh24:mi:ss'
                                 ) AS "WTRD_MODIFIED_DATE",
                            TO_CHAR (wmdtl.rtng_date,
                                     'MM/dd/yyyy'
                                    ) AS "WTRD_RTNG_DATE",
                            req.status_cid AS "PA_STATUS_CID",
                            TO_CHAR (req.modified_date,
                                     'MM/dd/yyyy'
                                    ) AS "PA_REQ_MODIFIED_DATE",
                            prs.state_pa_srvc_type_code
                                                     AS "STATE_PA_SRVC_TYPE_CODE",
                            wmdtl.wm_pa_task_rtng_dtl_sid
                                                        AS "WM_TASK_RTNG_DTL_SID",
                            wmdtl.assigned_to_user_acct_sid
                                              AS "WTRD_Assigned_to_user_acct_sid",
                            (fn_get_busniess_days (TRUNC (req.validity_start_date))
                            ) AS "Days<br>LeftSort",
                            wmdtl.assigned_to_org_unit_sid
                                                  AS "WTRD_Assigned_to_OrgUntSid",
                            DECODE
                               ((SELECT COUNT (*)
                                   FROM pa_request_status prs
                                  WHERE prs.pa_rqst_sid = req.pa_rqst_sid
                                    AND prs.status_cid = 5
                                    AND prs.oprtnl_flag = 'I'),
                                0, 'N',
                                'Y'
                               ) AS "SHOW_UTILIZATION"
                       FROM   pa_request req,
                             pa_certification_identifier pci,
                             status sts,
                             pa_request_x_member prxm,
                             wm_pa_task_routing_detail wmdtl,
                             pa_service_date psd,
                             org_unit ou,
                             pa_request_service prs,
                             pa_request_x_provider_location prxpl,
                             provider_location pl,
                             provider_detail pd,
                             provider p,
                             mbr_dmgrphc md
                      WHERE req.oprtnl_flag = 'A'
                        AND req.status_cid NOT IN
                                     (20, 30, 70, 25, 80, 96, 85, 5, 97, 98, 101)
                        AND req.org_unit_sid IN
                               (3057, 3142, 3058, 3143, 3059, 3144, 3060, 3145,
                                3061, 3146, 3062, 3147, 3063, 3148, 3064, 3149,
                                3065, 3150, 3066, 3151, 3067, 3152, 3068, 3153,
                                3069, 3154, 3070, 3155, 3071, 3156, 3072, 3157,
                                3073, 3158, 3074, 3159, 3075, 3160, 3076, 3161,
                                3077, 3162, 3078, 3163, 3079, 3164, 3080, 3165,
                                3081, 3166, 3082, 3167, 3083, 3168, 3084, 3169,
                                3085, 3170, 3086, 3171, 3087, 3172, 3088, 3173,
                                3089, 3174, 3090, 3175, 3091, 3176, 3092, 3177,
                                3093, 3178, 3094, 3179, 3095, 3180, 3096, 3181,
                                3097, 3182, 3098, 3183, 3099, 3184, 3100, 3185,
                                3101, 3186, 3102, 3187, 3103, 3003, 75000104,
                                75000108, 2006, 75000103, 75000102, 75000113,
                                75000111, 75000109, 2001, 2009, 75000105,
                                75000107, 2004, 2010, 2013, 2014, 2005, 2011,
                                75000112, 2002, 1001, 2012, 75000106, 2007,
                                75000101, 2003, 75000110, 2008, 3001, 3002, 3019,
                                3104, 3020, 3105, 3021, 3106, 3022, 3107, 3023,
                                3108, 3024, 3109, 3025, 3110, 3026, 3111, 3027,
                                3112, 3028, 3113, 3029, 3114, 3030, 3115, 3031,
                                3116, 3032, 3117, 3033, 3118, 3034, 3119, 3035,
                                3120, 3036, 3121, 3037, 3122, 3038, 3123, 3039,
                                3124, 3040, 3125, 3041, 3126, 3042, 3127, 3043,
                                3128, 3044, 3129, 3045, 3130, 3046, 3131, 3047,
                                3132, 3048, 3133, 3049, 3134, 3050, 3135, 3051,
                                3136, 3052, 3137, 3053, 3138, 3054, 3139, 3055,
                                3140, 3056, 3141)
                        AND req.pa_rqst_sid = prs.pa_rqst_sid
                        AND prs.oprtnl_flag = 'A'
                        AND prs.pa_rqst_srvc_sid = psd.pa_rqst_srvc_sid
                        AND psd.oprtnl_flag = 'A'
                        AND req.pa_rqst_sid = pci.pa_rqst_sid
                        AND pci.oprtnl_flag = 'A'
                        AND req.pa_rqst_sid = prxm.pa_rqst_sid
                        AND prxm.oprtnl_flag = 'A'
                        AND md.oprtnl_flag = 'A'
                        AND md.status_cid = 2
                        AND TRUNC (SYSDATE) BETWEEN md.from_date AND md.TO_DATE
                        AND prxm.mbr_sid = md.mbr_sid
                        AND ou.org_unit_sid = req.org_unit_sid
                        AND ou.oprtnl_flag = 'A'
                        AND req.pa_rqst_sid = prxpl.pa_rqst_sid
                        AND prxm.pa_rqst_sid = prxpl.pa_rqst_sid
                        AND pci.pa_rqst_sid = prxm.pa_rqst_sid
                        AND pci.pa_rqst_sid = wmdtl.subsystem_task_sid
                        AND pci.pa_rqst_sid = prxpl.pa_rqst_sid
                        AND prxpl.pa_prvdr_type_lkpcd = 'RR'
                        AND prxpl.oprtnl_flag = 'A'
                        AND req.status_cid = sts.status_cid
                        AND sts.status_type_cid = 3
                        AND sts.oprtnl_flag = 'A'
                        AND prxpl.prvdr_lctn_iid = pl.prvdr_lctn_iid
                        AND p.prvdr_sid = pd.prvdr_sid
                        AND p.prvdr_sid = pl.prvdr_sid
                        AND pd.oprtnl_flag = 'A'
                        AND pd.status_cid = 2
                        AND TRUNC (SYSDATE) BETWEEN pd.from_date AND pd.TO_DATE
                        AND wmdtl.subsystem_task_sid = req.pa_rqst_sid
                        AND wmdtl.subsystem_lkpcd = 'PA'
                        AND wmdtl.oprtnl_flag = 'A'
                        AND req.pa_rqst_date > (SYSDATE - 365)
                                       ORDER BY TO_DATE ("Request Date", 'MM/dd/yyyy hh24:mi:ss') DESC,
                            "Beneficiary Name" ASC) a
     WHERE ROWNUM < 102;
    Kind regards
    Prakash P

    Published by: BluShadow on May 17, 2011 15:01
    addition of {noformat}
    {noformat} tags around the code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                

    3360 wrote:
    See point 9 of this section of the FAQ on how to format the code.

    SQL and PL/SQL FAQ

    I see that you did.

    No, I did. It's pretty easy to change if the code seems formatted anyway below. It's when I go to edit the message and find no sense because it is not formatted in all cases, I despair. {noformat} :) {noformat}

  • Sub query problem

    Hi all

    Problem with sub query.

    Select * from where the team team_id in (team_id region selection);

    If I run the query above is the length, but the problem is that I don't have team_id in the region table. How oracle to run this query. Please explain.

    If I run select region team_id;

    I got error like team_id invalid.


    I'm using the version of oracle 10g.


    Thank you.

    Sunita.

    sunitha2010 wrote:
    Hi all

    Problem with sub query.

    Select * from where the team team_id in (team_id region selection);

    If I run the query above is the length, but the problem is that I don't have team_id in the region table. How oracle to run this query. Please explain.

    Because of the determination of the scope.
    Oracle uses the "team_id" of the outer query.

    If you were to use:

    select * from team  where team_id in (select region.team_id from region);
    

    THEN, you will get an error.

  • Need help to write a sub query

    Our environment - Oracle 10 g

    Hi all
    Need help to write a sub query to reach him here are examples of data using which iam trying to replace the value column in the table based on two other columns in the same table

    Examples of data

    ClaimNo flag LineNo Procedurecode
    100 01 N MN4567
    100 02 Y 7863
    100 03 N MN8976
    100 04 Y 9000
    101 01 Y 8954
    101 02 N MN6754
    101 03 N MN7654
    101 04 Y 8976
    102 01 Y 1234
    102 02 Y 2345
    102 03 Y 3456
    102 03 Y 4567

    Each column of ClaimNo has several rows of data. But if column procedurecode for a claimNo starts with MN then all values associated with the claimno for the flag column should replace N

    If the data must become like below

    ClaimNo flag LineNo Procedurecode
    100 01 N MN4567
    100 02 N 7863
    100 03 N MN8976
    100 04 N 9000
    101 01 N 8954
    101 02 N MN6754
    101 03 N MN7654
    101 04 N 8976
    102 01 Y 1234
    102 02 Y 2345
    102 03 Y 3456
    102 03 Y 4567


    Thank you

    See the example:

    with t as (
                  select 100 ClaimNo, '01' LineNo, 'N' Flag, 'MN4567' Procedurecode from dual
        union all select 100, '02', 'Y', '7863' from dual
        union all select 100, '03', 'N', 'MN8976' from dual
        union all select 100, '04', 'Y', '9000' from dual
        union all select 101, '01', 'Y', '8954' from dual
        union all select 101, '02', 'N', 'MN6754' from dual
        union all select 101, '03', 'N', 'MN7654' from dual
        union all select 101, '04', 'Y', '8976' from dual
        union all select 102, '01', 'Y', '1234' from dual
        union all select 102, '02', 'Y', '2345' from dual
        union all select 102, '03', 'Y', '3456' from dual
        union all select 102, '03', 'Y', '4567' from dual
    )
    select
        claimno,
        lineno,
        flag,
        case
          when count(decode(substr(procedurecode,1,2),'MN',1)) over(partition by claimno)>0
            then 'N'
          else flag
        end new_flag,
        procedurecode
    from t
    

    Kind regards
    Sayan M.

  • How can I create a query with the data control to the web service?

    I need to create a query with the order of web service data, WSDL, it is query operation, there is a message of parameter with possible query criteria and a return message contains the results. I googled but can't find anything on the query with the web service. I can't find a criterion "named" to the data control of web service as normal data control. Blog of Shay, I saw the topics on the update with the data of web service command. How can I create a query with the data control to the web service? Thank you.

    Hello

    This might help

    * 054.     Search form using control data WS ADF and complex of entry types *.

    http://www.Oracle.com/technetwork/developer-tools/ADF/learnmore/index-101235.html

  • update with order by

    Hi all

    Does anyone know if "in order to" has the priority on "updates"? In other words, by using the following query. Will be sorted first and then locked resulting lines or they will be locked everything first, and then sorted?

    SELECT / * + cardinality (para. 1) use_nl (al t) * / NULL
    LOOSE COLLECTION l_nullvalue_list
    TABLE (i_list), my_table t Al
    WHERE al.id = t.id
    ORDER BY t.id
    FOR the UPDATE OF t.id;

    Any help is appreciated.

    Kind regards
    WF

    It is the case that I do not speak:

    drop table t cascade constraints purge;
    create table t as select rownum id, cast('x' as char(100)) pad
                        from dual connect by level <= 10000;
    
    drop table t1 cascade constraints purge;
    create table t1(id int);
    
    -- 1st session
    SQL> lock table t1 in exclusive mode;
    
    Table(s) locked
    
    -- 2nd session
    declare
        type t1_type is table of rowid index by binary_integer;
        l_tab t1_type;
    begin
        execute immediate 'lock table t1 in share mode';
        select rowid bulk collect into l_tab
          from t order by dbms_random.value
           for update;
    end;
    /
    
    -- 3rd session
    declare
        type t1_type is table of rowid index by binary_integer;
        l_tab t1_type;
    begin
        execute immediate 'lock table t1 in share mode';
        select rowid bulk collect into l_tab
          from t order by dbms_random.value
           for update;
    end;
    /
    

    Now 2nd & 3rd sessions are blocked by the 1st. We will release the lock:

    -- 1st session
    SQL> commit;
    
    Commit complete
    

    2nd & 3rd sessions try to lock the rows of the table T, and fails one of the sessions with blocking:

    declare
        type t1_type is table of rowid index by binary_integer;
        l_tab t1_type;
    begin
        execute immediate 'lock table t1 in share mode';
        select rowid bulk collect into l_tab
          from t order by dbms_random.value
           for update;
    end;
    
    ORA-00060: deadlock detected while waiting for resource
    ORA-06512: at line 7
    

    If you repeat the same scenario with ORDER BY id, then a session will wait to enqueue.
    So, it's all on the order in which the row locks are acquired.

Maybe you are looking for

  • Can I still call the phone numbers?

    I kept only Skype because I can dial international telephone numbers and save them - to the client sessions, etc. I just got a new computer with Windows 10 and Skype version 2.15 and I don't see a place where I get a touchpad and dial a number. It se

  • SAMSUNG SSD very slow external T1 to El captain

    Since then, I've updated my iMac k 5-El Captain my external Samsung Q1 SSD starts very slowly and access is also very slow. This also reduced the mail sending speed with attachment of this SSD at very slow speed. Before the high-speed T1.

  • In palette I can find 'Write to worksheet File.vi' in 2015 of Labview?

    I get the signal from a sensor in DAQ hardware. After this treatment, I have three columns. Signal time - average - standard deviation I have trouble writing in an excel file. I used "Write to measure file.vi" but I don't know how to add columns insi

  • Automatic updates is now paused.

    Hello can someone tell me what the problem is on my sbs server it gives me an error message that my automatic updates is now suspended. my event ID is 27. Microsoft-Windows-WindowsUpdateClient event source would love to hear from you

  • BATTERY CHANGE CMOS ON ASPIRE M3200 NOW GET WARNING "OPEN CHASSIS. ANY HELP TO SOLVE?

    Acer Aspire M3200 Recently changed CMOS battery due to loss of date however now keep wake up American Megatrends 'Chassis opened warning' at startup. Have tried to reset / disable in the Bios but not listed is not in the tabs on the security features