Query Oracle - to display the line in the Condition column in function.

Hi all

I have data like below.

ID of ranking name Desc

========================

1             ID1          A              AA1

2             ID1          A              AA2

1             ID1          B              BB1

2             ID1          B              BB2

1             ID2          C              CC1

2             ID2          C             CC2

1             ID2          D             DD1

2             ID2          D             DD2

I need the query to retrieve the data as below.

ID of ranking Name1 Name2

==================================

ID1 1 A - AA1 B - BB1

1 ID2 CC1 - C D - DD1

That is to say) Condition: Grade must be 1.

Thank you and best regards,

Stéphane.

with

DATA_TABLE as

(select 1 Rank, ID 'ID1', 'A' name, Descr "AA1" of union double all the)

Select 2, 'ID1', 'One ', ' AA2' Union double all the

Select 0, 'ID1', 'B', "BB1" dual union all

Select 3, 'ID1', 'B', 'BB2' from dual union all

Select 2, 'ID2', 'C', 'CC1' from dual union all

Select 3, 'ID2', 'C', 'CC2' from dual union all

Select 1, 'ID2', would be ', 'DD1"dual union all

Select 3, 'ID2', would be ', 'DD2' from dual

)

SELECT id, Name1, name2

go (select id,

name_desc_rank,

ROW_NUMBER() over (partition by order of identification by name_desc_rank) rn

go (select grade,

ID,

name | '-' || descr | '-' || TO_CHAR (Rank) name_desc_rank,

ROW_NUMBER() over (partition by order of rank identification) rn

of data_table

)

where rn<=>

)

Pivot (Max (name_desc_rank) of rn (1 as name1, name2 2))

ID NAME1 NAME2
ID1 A-1 AA1 B-BB1-0
ID2 C CC1-2 D DD1-1

Concerning

Etbin

Tags: Database

Similar Questions

  • How to display the comments column in Windows Media Player 12?

    WMP12 - how to display the comments column?

    I want to see the Cooments ColonneB in my WMP ads, but it is not giving me the option.

    Hello

    1. What do you mean exactly by the column comments?
    2. are you referring to in Windows Media Player?

    If you want to change the information contained in the Windows Media Player, you can follow the steps in this article.

    http://Windows.Microsoft.com/en-us/Windows7/add-or-edit-media-information-in-Windows-Media-Player

  • SQL query to meet all the conditions.

    ID of country client_name

    a                      india        1

    a                     US            1

    oneWE1

    b                      india         1

    c                      india        1

    c                      india         1

    c                      india         1

    c                     us             1

    c                    US            1

    If I do a count if the id of group by client_name and country column I'll get value like that...

    client_name country count (id)

    a                  india          1

    a                    US          2

    b                  india          1

    c                  india          3

    c                   US           2

    Condition of the obligation:

    (1) if the customer is in effect in several countries then show that the customer and country having count (id) > 2, (over the case it will be customer = 'b' and country India, country will be us skip)

    (2) if the customer is does not exist in several countries then show that client and default country (in above cases it will be customer = 'b') while count (id) is less than 2., we show him...

    Catch for me is :-also, we should not ignore any customer... so, as in a. customer... as count (id) for the two countries is not more than 2... so, as per above logic... this client will ignore if we apply only above two conditions

    but we need to show the customer in this case... and take the two value... so my end result I need will be:

    customer country

    a India

    a                    US

    b the India

    c India

    Please suggest the query to achieve even... I am able to get the query that meets condition 1 and condition 2. but failure to have taken also in request... so in my query output is all above, except customer one is ignored

    Thank you very much!

    Hello

    I think I see.  You want to display the lines of 'best' available for any client, where the lines with a COUNT (*) 2 > are 'better' than the lines with COUNT (*) <= 2. ="" if="" a="" client="" has="" any="" rows="" with="" count="" (*)="">2, then to display the lines were COUNT (*) > 2, but if all the lines for a customer have COUNT (*)<= 2,="" then="" those="" are="" the="" "best"="" rows="" available,="" so="" you="" want="" to="" show="" them. ="" how="" many="" different="" countries="" a="" client="" is="" related="" to="" doesn't="">

    I always CREATE TABLE and INSERT statements for your sample data, so I'll we table scott.emp to illustrate.  Instead of customer and country, as at your table, we will use deptno and job.  This query:

    SELECT deptno, job

    AS cnt ACCOUNT (*)

    FROM scott.emp

    GROUP BY deptno, job

    ORDER BY deptno, cnt

    ;

    display the relevant data, i.e.:

    DEPTNO JOB CNT

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

    10. THE CHAIRMAN 1

    MANAGER 10 1

    10 1 CLERK

    20 MANAGER 1

    20 2 ANALYST

    20 CLERKS 2

    30 1 CLERK

    30 1 MANAGER

    30 4 SELLER

    But we don't want to show all the data.  We want to only show the best available for each deptno line type, where the lines with the cnt > 2 (let's call these lines of class 'A') are better then with the NTC<= 2="" (let's="" call="" these="" class="" 'b'="" rows.) ="" the="" output="" we="" want="">

    DEPTNO JOB CNT

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

    10. THE CHAIRMAN 1

    10 1 CLERK

    MANAGER 10 1

    20 CLERKS 2

    20 MANAGER 1

    20 2 ANALYST

    30 4 SELLER

    Deptnos 10 and 20 only have rows of 'B' class, if we want to display the lines of 'B' class for these deptnos.  DEPTNO 30 has at least 1 row of class 'A', so we only show the lines of 'A' class of deptno = 30.  This is an example of a Query of Top - N, and here's a way to do it:

    WITH got_r_num AS

    (

    SELECT deptno, job

    AS cnt ACCOUNT (*)

    DENSE_RANK () OVER (PARTITION BY deptno

    ORDER OF CASES

    WHEN COUNT (*) > 2

    THEN "A".

    OF ANOTHER 'B '.

    END

    ) AS r_num

    FROM scott.emp

    GROUP BY deptno, job

    )

    SELECT deptno, job, cnt

    OF got_r_num

    WHERE r_num = 1

    ;

  • Oracle, equivalent to the SQL SERVER CLRClipString function

    Hello friends,

    I am running the following sql query in SQL SERVER successfully...

    Select * from
    CLRSplitString ('33, 54, 105, 148, 149, 163, 165, 179, 193, 195, 201, 202, 234, 239, 279, 282, 297, 299, 329, 332, 350, 415, 417, 439, 440, 500, 552, 570, 589, 603, 628, 655', ", ',') x
    Join dbo. PART_ADDL_INFO_NAMES_V v x.col1 = v.addl_info_name_id

    I would like to implement the same ORACLE sql statement.

    I created the function that takes the comma-separated string and display as a single column... I want emerging in oracle as a sql statement...


    create or replace function str2tbl
    (p_str in varchar2)
    p_delim in varchar2 default '.')
    return myTableType
    as
    long l_str p_str default. p_delim;
    number of l_n;
    myTableType l_data: = myTabletype();
    Start
    loop
    l_n: = instr (l_str, p_delim);
    When the output (nvl(l_n,0) = 0);
    l_data.extend;
    l_data (l_data.count): = ltrim (rtrim (substr(l_str,1,l_n-1)));
    l_str: = substr (l_str, l_n + length (p_delim));
    end loop;
    L_data return;
    end;
    /

    DECLARE
    v_array mytabletype;
    BEGIN
    v_array: = str2tbl ('10.01.03.04.234');
    BECAUSE me in 1... v_array. COUNTING LOOP
    DBMS_OUTPUT. Put_line (v_array (i));
    END LOOP;
    END;
    /
    10
    01
    03
    04
    234


    appreciate your help...

    Thank you

    If you need to split a single string:

    with t as (
               select '33,54,105,148,149,163,165,179,193,195,201,202,234,239,279,282,297,299,329,332,350,415,417,439,440,500,552,570,589,603,628,655' str from dual
              )
    select  regexp_substr(str,'[^,]+',1,level) sub_str
      from  t
      connect by level <= regexp_count(str,',') + 1
    /
    
    SUB_STR
    -------------------
    33
    54
    105
    148
    149
    163
    165
    179
    193
    195
    201
    
    SUB_STR
    -------------------
    202
    234
    239
    279
    282
    297
    299
    329
    332
    350
    415
    
    SUB_STR
    -------------------
    417
    439
    440
    500
    552
    570
    589
    603
    628
    655
    
    32 rows selected.
    
    SQL> 
    

    SY.
    PS REGEXP_COUNT is available in 11g only. If you are using 10g:

    with t as (
               select '33,54,105,148,149,163,165,179,193,195,201,202,234,239,279,282,297,299,329,332,350,415,417,439,440,500,552,570,589,603,628,655' str from dual
              )
    select  regexp_substr(str,'[^,]+',1,level) sub_str
      from  t
      connect by level <= length(regexp_replace(str,'[^,]')) + 1
    /
    
  • How to display the database column value in a component of choice selected?

    Hello everyone;

    I use Jdeveloper 11.1.1.4 and right now I have the .jspx UI page that includes < af:selectonechoice / > components and according to the requirment I have to fill one of the column in the table in this drop-down list.

    can someone tell me how to fill the database column value in this drop-down list. I know I need to create the VO for the same thing, but I'm new to this technology. Then please suggest.

    Thanks in advance.,

    This will help u

    https://blogs.Oracle.com/prajkumar/entry/create_lov_in_adf_application

    How to create LOV in ADF 11 g | Techartifact

    Oracle Fusion Middleware Technologies: 11G: how to create a list of Values (LOV)?

    http://www.baigzeeshan.com/2010/03/creating-lov-in-ADF-application.html

    http://husaindalal.blogspot.de/2010/05/How-to-default-lov-with-its-first-value.html

  • Valueset TABLE based at SSHRC does not display the additional columns

    Hello

    I created a valueset, which is the base of the table. I added a column in the extra column. I use this valueset in an EIT. I created a page of SSHRC s for the EIT.

    My problem is, that valueset shows the additional column when you open the valueset in EIT of FORMS, but does not show the additional column on the page of SSHRC.  Is this a bug?


    Hi Alex,

    I have the solution for this. Basically, you specify the alias column name and specify the width with it.

    for example: aa.segment1 'Destination' (20)

  • Reports - the values of the checkbox and the conditional column visibility

    Although I use Oracle databases for many years, I must admit that I am rather new to APEX. I build a first prototype project to convince our project managers and managers of the usefulness of the product for future projects (as for interfaces Visual of the database where the focus is on forms and reports, it is often quicker and cheaper to build an APEX application instead of a webapp in Java or c# full blown).

    I have a few problems however.

    I'll start with a quick description. I have the following structures of parent/child:

    Provinces > cities > Intersections > earrings > detections in loop.

    Basically, I want to do a report on detections of loop. Now, as we have thousands of detections someday, I did kind of a mining structure down. First, you choose your province, then the city, then the intersection and finally the loop. Do not use the lists to make the selection. Instead, I did a (classic) report on each side because it allows me to give detailed information for each part. In each report, I made a link on the identifier. For example, when I select a province (by clicking on the link), I pass the identifier of the province of cities report and use it in the query to restrict my report to these cities in the province. I repeat these step for different parts, which, in the end, gives me the selected loop loop detections. The good news is that all this works very well. However, the person who will use this application made a suggestion and asked if it would be possible to select different loops and thus get the detections for several loops (the rest of the application remains the same). However, this means that I can't use the link in the column more. Now, I thought in the sense of a checkbox control. The link to the column is still there, but the user would also have the possibility to select several items in the report. I have managad to add a checkbox control to the report, associated with the loop identifier column. It's not really hard. I can't understand, however, how I can pass the identifiers found in the next report (detections for the selected loops) and use it in the report's underlying query. The problem is, I do not know how to pass the values checked to the next page and how to use these values in the request of the State of this page. I guess it must be possible, but I couldn't figure out how. I tried to play with APEX_APPLICATION. G_Fxx and others. Don't forget I'm a newbie and this seems to be more advanced features.

    I downloaded the images from the 2 on the pages of the report to illustrate:

    http://img96.imageshack.us/img96/1497/apex01.jpg

    http://img140.imageshack.us/img140/9868/apex02.jpg

    A second point that's bothering me is this. In the loop detection report, I show a link column (I chose an icon instead of the value of the column) for each line. I also have a column that displays the number of detections for the given line (and one day). Now, for some lines, there is no detection that has emerged. Therefore, there is no point in the selection of this loop, because the result will be a blank report. However, I still want to show the loop in the loop selection report, as it is always present (it is not as if he suddenly disappeared). Of course, no big problem and most users probably have sufficient intelligence to understand this. However, it would be nice if I could do the icon (link colum) visible only for these loops with detections, or in other words, for these recordings in which number_of_detections (COUNTY of underlying column) is greater than 0. I couldn't find a way to do it either. The conditional display for a column option didn't really offer me a solution here.

    Before I forget, I use APEX 4.0.1 on an Oracle XE database.

    Any advice or suggestions would be welcome! :)

    Thank you.

    Erwin

    Hello

    You mean something as in this example
    https://Apex.Oracle.com/pls/OTN/f?p=40323:55

    You can store the values checked into collection and then use it in another report where clause

    See for example this post for how you can memorize checked lines to the collection
    Re: Need help with APEX_Collection

    In the sample report DEPT query is

    SELECT
      CASE WHEN EXISTS(SELECT 1 FROM emp e WHERE e.deptno = d.deptno) THEN
        APEX_ITEM.CHECKBOX(1,c.c002,'onclick="saveDeptChk(this,'||c.seq_id||')"','true')
      END AS row_selector,
      c.c002 AS checked,
      d.DEPTNO,
      d.DNAME,
      d.LOC
    FROM dept d,
      apex_collections c
    WHERE c.collection_name = 'DEPT_CHK_COLLECTION'
      AND d.deptno = c.c001
    

    And the report on EMP

    SELECT e.EMPNO,
      e.ENAME,
      e.JOB,
      e.MGR,
      e.HIREDATE,
      e.SAL,
      e.COMM,
      e.DEPTNO
    FROM emp e,
      apex_collections c
    WHERE c.collection_name = 'DEPT_CHK_COLLECTION'
      AND c.c002 = 'true'
      AND e.deptno = c.c001
    

    Kind regards
    Jari

  • security of the row/column in function

    Hello

    We have the necessary specific company, which is linked to motor vehicle liability insurance. There are many insurance companies, which have joined into a single fund. All claims and contracts are in the single data warehouse. Each line of data (for example, in the table of recreational vehicles) has a column that contains the ID of an insurer.

    The problem is that this data warehouse will be used for analytical purposes, for example, to calculate the cost of insurance. For this operation the insurance companies need data for the whole of the market (Fe: all insured red BMW-s). A few details (reg. No. a car) of each returned row can be visible for the company, whose ID matches the value of the insurer_ID column.

    Example:

    Table: vehicles
    V_ID | do | color | reg_no | insurer_ID
    123 | BMW | Red | 123ABC | 11
    234. BMW | Red | 456QWE | 22

    Insurer with ID 11 querys table:
    Select * from vehicles where do = 'BMW' and color = 'red ';

    Oralcle should return:
    V_ID | do | color | reg_no | insurer_ID
    123 | BMW | Red | 123ABC | 11
    234. BMW | Red | NULL | NULL VALUE

    Is this possible with the native tools of Oracle?

    First variant would be, that there is a query layer, which splits the query in to separate phrases and returns the results to new bundle:

    Select * recreational vehicle where do = 'BMW' and color = 'red' and insurer_ID = '11';
    Select vehicle_ID, make, color of vehicles where do = 'BMW' and color = 'red' and insurer_ID! = "11";

    Query layer must also restore:
    V_ID | do | color | reg_no | insurer_ID
    123 | BMW | Red | 123ABC | 11
    234. BMW | Red | NULL | NULL VALUE

    Second solution would be separate tables, one that contains sensitive data and other data not delicate, between those who must be described in a table relationships. On the first table there is a view for each third party returns authorized only lines.

    Is there an existing case study for this kind of business needs?

    Version of database is Oracle 11 g Standard.

    Best regards
    Erki Pettai
    Analyst
    Proekspert Ltd

    We can make our own implementation of VPD using views. It's not too bad for RLS, but it's a little gross to CLS.

    The basic idea is to set a namespace or a context that is defined using dbms_session.set_context () and then referenced in the view by using sys_context(). In your scenario, you do not want to fill the frame with the company ID whenever someone logs in. (Obvously this kind of thing is gnarlier in stateless web applications). Your opinion would then be something watch this...

    
    create or replace view restricted.vehicles as
    select V_ID
           , make
           ,  color
           , case when insurer_ID = sys_context('your_namespace', 'company_id') then reg_no else null end as reg_no
           , case when insurer_ID = sys_context('your_namespace', 'company_id') then insurer_ID else null end as insurer_ID
    from restricted.vehicles
    /
    

    Note the schema name: you must make sure that the tables are not visible to other users, that point of view. A safer solution would still be two levels of views. At the external level selects just * the internal level. At the external level is believe that gave himself and therefore protects statement of the view from prying eyes.

    You will find the simple line-level stuff - just put in the WHERE clause of the view.

    Because you are running a data warehouse, I suppose that you are spared the inconvenience of trying to manage updates, etc. in this way.

    This course is a Joseph and will be a bit of a nightmare to maintain, especially if you have a lot of tables that you want to protect. That's why Oracle do you want to pay for the license of the company.

    Good luck.

    Cheers, APC

    blog: http://radiofreetooting.blogspot.com

  • Link of the conditional column in classic report

    I am tring to display a link in a column only if another column has a value in the same row. However, the column, I try to display conditionally must call a javascript function when the click on (it pops up a modal window) and it must include an image.

    My report request is

    Select

    AC. C001,

    AC. C015

    apex_util.prepare_url ('f? p = & APP_ID.:4: & SESSION.: &. DEBUG: P4_PARCEL_ID:' | ac.c001) LINK_URL,-my link conditional image onclick

    Of apex_collections ac

    WHERE collection_name =: P3_COLLECTION_NAME

    Report of the attribute COLUMN BINDING settings are:

    LINK ATTRIBUTE: < img src = "" #WORKSPACE_IMAGES #fff_report.png "/ >"

    URL: javascript:mymodal('#LINK_URL#','View_Comments')

    It works, but it shows the picture report.png on each line of the report. I need to combine the link attribute and the url in the statement select with a CASE to view statement conditionally cela but I can't get the good constructed string... can help any one?

    I'm looking for

    SELECT

    case if ac.c015 is not null then

    apex_util.prepare_url ('f? p = & APP_ID.:4: & SESSION.: &. DEBUG: P4_PARCEL_ID:' | ac.c001) LINK_URL (add on the image and appeal of javascript...?)

    on the other

    null

    end LINK_URL

    Of...

    Thank you

    Andy

    Hi Andy,.

    It works for me, it will help to prepare the good instruction box with pictures and without images

    Select 'Remove from cart' of the double

    -Sunil Bhatia

  • expression of the condition as a function?

    Is it possible to put some checks in a function?

    Example:
    SELECT * FROM A WHERE A.x < 50 and A.x+A.y > 0 and A.y < p_variable;
    As I will use a similar condition in many places (in a box) I look at what makes a function, something like this:
    SELECT * FROM A WHERE func1(A.x, A.y, p_variable);
    One problem is that a function cannot return a value of truth.

    No idea how to approach this problem?

    Kind regards
    David

    Looks like your function should return the subitem_code if the user has access to this subitem_code.
    If he doesnot have the permission, the query should not return any result.

    Then create your function like this, but remember that you will hit the fuction for each row of table A.

    CREATE OR REPLACE FUNCTION fnc_check (p_user         IN access_table.USER%TYPE,
                                          p_permission   IN access_table.permission,
                                          p_subitemcode  IN access_table.subitem_code)
       RETURN access_table.subitem_code%TYPE
    IS
       l_num   NUMBER := 1;
    BEGIN
       SELECT DISTINCT 1
         INTO l_num
         FROM access_table
        WHERE USER = p_user
          AND permission = p_permission
           AND subitem_code = p_subitem_code;
    
       RETURN p_subitemcode;
    EXCEPTION
       WHEN NO_DATA_FOUND
       THEN
          RETURN NULL;
    END;
    

    And your interior will be like this,

    procedure p1(user_id in NUMERIC, query_parameter_1 IN NUMERIC, query_parameter_2 IN VARCHAR2, result out SYS_REFCURSOR)
    IS
    begin
        open result for
        SELECT A.*
        FROM A
        WHERE
            A.foo =  query_parameter_1
            AND
            A.bar LIKE  query_parameter_2
            AND
            A.subitem_code = fnc_check(user_id, 'READ_TABLE_A', A.subitem_code);
    end;
    

    G.

  • Query - Gohan values in the following columns of aging

    Oracle 11.2.0.3...

    I have this query... working on it in SQL * Navigator.

    We pay all suppliers with Net 20, 25 Net and Net 30 terms due date + 15 days. I'm developing an application that will tell me who is due now, which must be returned within next 7, then 10, then 14 and coming 21 days.

    The following query returns not due, owed, due + 7, etc... but just what is due is also displayed in the + 7, + 10, etc - because if it's due, it will be always due in a week!

    How can I remove these values if they are already due?

    (or, if they are due in 7 days, how can I delete + 10, + 14, etc?)


    SELECT
    PV. $vendor_name "seller."
    NPS.invoice_number "Bill."
    NPS.invoice_date "Date of the invoice.
    NPS.due_date "due date."
    Inv.Terms "terms."
    (TO_DATE (sysdate) - nps.invoice_date) "Days entries."
    (CASE
    When to_date (nps.due_date) < to_date (sysdate)
    then (to_date (sysdate) - to_date (nps.due_date))
    Another null
    end) 'days overdue',
    "Remaining amount", NPS.amount_remaining
    --0-15
    (CASE
    WHEN (TO_DATE (sysdate) - nps.invoice_date) < 45
    THEN nps.amount_remaining
    ANOTHER NULL
    END
    ) "Unmatured,"
    (CASE
    WHEN (TO_DATE (sysdate) - nps.invoice_date) > = 45
    THEN nps.amount_remaining
    ANOTHER NULL
    END
    ) "Have."
    (CASE
    WHEN (TO_DATE (sysdate + 7) - nps.invoice_date) > = 45
    THEN nps.amount_remaining
    ANOTHER NULL
    END
    ) '+ 7 days. "
    (CASE
    WHEN (TO_DATE (sysdate + 10) - nps.invoice_date) > = 45
    THEN nps.amount_remaining
    ANOTHER NULL
    END
    ) '+ 10 days. "
    (CASE
    WHEN (TO_DATE (sysdate + 14) - nps.invoice_date) > = 45
    THEN nps.amount_remaining
    ANOTHER NULL
    END
    ) '+ 14 days. "
    (CASE
    WHEN (TO_DATE (sysdate + 21) - nps.invoice_date) > = 45
    THEN nps.amount_remaining
    ANOTHER NULL
    END
    ) "21 days".
    Of
    Inv,
    PV,
    NPS
    WHERE
    and nps.amount_remaining <>0
    and inv.terms ("Net 20', ' Net 25', 'Net 30')


    example of output:
    Invoice date of invoice terms due Date day days entered late amount not remaining due not due 7 days + 10 days + 14 days + 21 days
    seller 00470871 1 12/27/1 / 2012/2013 Net 30 12 126,62 126.62 26
    provider 59355648 2 11/28/2012 12/28/2012 Net 30 41 11 538,75 538.75 538,75 538.75 538,75 538.75
    the seller 3 75793062 12/4/1/3 of 2012/2013 Net 30 35 5 950 950 950 950 950
    seller 4 52835 12/13/1 / 2012/2013 Net 30 26 298.92 13 298,92 298.92
    seller 4 52814 12/4/1/3 of 2012/2013 Net 30 35 5 330 330 330 330 330

    any sql gurus have ideas?

    Published by: camforbes on January 8, 2013 13:24

    Hello

    It's not very clear what you want, but I think something more or less like that will do what you want:

    WITH    got_grp            AS
    (
         SELECT  pv.vendor_name
         ,     nps.invoice_number
         ,     nps.invoice_date
         ,     nps.due_date
         ,     inv.terms
         ,     SYSDATE - nps.invoice_date     AS days_entered
         ,     CASE
                   WHEN  nps.due_date < SYSDATE
                   THEN  SYSDATE - nps.due_date
                   ELSE  NULL
              END                    AS days overdue
         ,     nps.amount_remaining
         ,     CASE
                   WHEN  nps.invoice_date  > SYSDATE - 24     THEN  'Over 21 Days'
                   WHEN  nps.invoice_date  > SYSDATE - 31     THEN  '+21 Days'
                   WHEN  nps.invoice_date  > SYSDATE - 35     THEN  '+14 Days'
                   WHEN  nps.invoice_date  > SYSDATE - 38     THEN  '+7 Days'
                   WHEN  nps.invoice_date  > SYSDATE - 45     THEN  'Due'
                                                                   ELSE  'Not Due'
              END                         AS grp
         FROM     inv
         JOIN     pv     ON ...
         JOIN     nps     ON ...
         WHERE     nps.amount_remaining     != 0
         AND      inv.terms           IN ('Net 20', 'Net 25', 'Net 30')
    )
    SELECT  pv.vendor_name
    ,     nps.invoice_number
    ,     nps.invoice_date
    ,     nps.due_date
    ,     inv.terms
    ,     days_entered
    ,     days overdue
    ,     CASE  WHEN grp = 'Not Due'  THEN amount_remianing END     AS not_due
    ,     CASE  WHEN grp = 'Due'      THEN amount_remianing END     AS due
    ,     CASE  WHEN grp = '+7 Days'  THEN amount_remianing END     AS plus_7_days
    ,     CASE  WHEN grp = '+14 Days' THEN amount_remianing END     AS plus_14_days
    ,     CASE  WHEN grp = '+21 Days' THEN amount_remianing END     AS plus_21_days
    FROM     got_grp
    ;
    

    Whenever you have a question, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
    If the results are dependent on when the query is run, give an exact time of execution, or better yet, give a couple of different run times and desired outcomes, the same sample for each data.
    Explain, using specific examples, how you get these results from these data.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).
    See the FAQ forum {message identifier: = 9360002}

  • Displays the empty columns instead of data

    I grew up a table from data source in the physical layer. I checked the data in the view, and there are data for all columns.
    I need to create a report of this table (only). All the fields, I need to create the report exist in the same table. I didn't need another table to create this report.
    But just for the sake of creating joins, I joined with a fact table in the physical layer and in the same way, at a table of dimension and/or fact in MDB table.
    I created the report and the data is not displayed for columns 4 and 5. It displays empty for these columns.
    Help, please.

    Hello
    try to purge the cache of the administrator and close all cursors to manage the side sessions answers then try to run the report.
    Also check the properties of the columns in the physical layer to see the length defined for the column.

  • Oracle index on the specified columns

    Hello

    I read Oracle index to improve the performance of database engines when searching for data.
    Therotically I know, but practically, did not write all the indexes in fact.

    For example, we have a lower index in our Application:


    CREATE a UNIQUE M_Index INDEX on F_SECTION ("FMAT_ID", "SECT_NAME")

    PCTFREE, INITRANS 10 2 MAXTRANS 255

    STORAGE (INITIAL NEXT 16384 16384 MINEXTENTS 1 MAXEXTENTS 121)
    PCTINCREASE 50 FREELISTS 1 FREELIST GROUPS 1 DEFAULT USER_TABLES)
    TABLESPACE 'SYSTEM '.



    I saw here for questioning, this table F_SECTION consists of several columns under him, but someone please tell me why is that the Index has been created according to only the columns.

    waiting for your ideas, thank you in advance.

    Hello

    I read Oracle index to improve the performance of database engines when searching for data.
    Therotically I know, but practically, did not write all the indexes in fact.

    For example, we have a lower index in our Application:

    CREATE a UNIQUE M_Index INDEX on F_SECTION ("FMAT_ID", "SECT_NAME")

    PCTFREE, INITRANS 10 2 MAXTRANS 255

    STORAGE (INITIAL NEXT 16384 16384 MINEXTENTS 1 MAXEXTENTS 121)
    PCTINCREASE 50 FREELISTS 1 FREELIST GROUPS 1 DEFAULT USER_TABLES)
    TABLESPACE 'SYSTEM '.

    Hello

    During the design phase of database, the database modelers would have done the combination of 'FMAT_ID' and 'SECT_NAME' as primary key that uniquely identifies the record in your table.

    Kind regards
    Claudy

  • oracle database of the calling user-defined functions

    Hi, are there ways to call oracle database functions defined by the user of the RPD or queries?

    I think that it not there no.

    But there may be some ways that I don't know.

    Thank you!

    Yes, there is.

    The function EVALUATE obiee.

    Document:
    http://www.Oracle.com/technology/products/bi/PDF/Oracle%20Business%20Intelligence%20Server%20and%20Embedded%20dB%20Functions.PDF

    You can call defined by the user or the functions of the database system.

    O address:
    http://108obiee.blogspot.com/search/label/evaluate

    Concerning
    Goran
    http://108obiee.blogspot.com

  • Improve a simple select query that uses all the lines.

    Hi all

    Excuse me if the question is too dumb. Here is my code
    SQL> select * from v$version;
    
    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    
    Elapsed: 00:00:00.07
    SQL> show parameter optim
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    object_cache_optimal_size            integer     102400
    optimizer_dynamic_sampling           integer     2
    optimizer_features_enable            string      10.2.0.1
    optimizer_index_caching              integer     0
    optimizer_index_cost_adj             integer     100
    optimizer_mode                       string      ALL_ROWS
    optimizer_secure_view_merging        boolean     TRUE
    plsql_optimize_level                 integer     2
    
    SQL> explain plan for select SUM(decode(transaction_type,'D',txn_amount,0)) payments_reversals,
      2          SUM(decode(transaction_type,'C',txn_amount,0)) payments,primary_card_no,statement_date
      3             from credit_card_pymt_dtls  group by primary_card_no,statement_date;
    
    Explained.
    
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    -----------------------------------------------------------------------------------------------------------------------
    -----------------------------------
    Plan hash value: 2801218574
    
    ----------------------------------------------------------------------------------------------------
    | Id  | Operation          | Name                  | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |                       |  1912K|    56M|       | 21466   (3)| 00:04:18 |
    |   1 |  SORT GROUP BY     |                       |  1912K|    56M|   161M| 21466   (3)| 00:04:18 |
    |   2 |   TABLE ACCESS FULL| CREDIT_CARD_PYMT_DTLS |  1912K|    56M|       |  4863   (3)| 00:00:59 |
    ----------------------------------------------------------------------------------------------------
    
    9 rows selected.
    
    SQL> select index_name,index_type
      2  from all_indexes
      3  where table_name = 'CREDIT_CARD_PYMT_DTLS';
    
    INDEX_NAME                     INDEX_TYPE
    ------------------------------ --------------------
    INDX_TRANTYPE                  BITMAP
    INDX_PCARD                     NORMAL
    INDX_PSTATEMENT_DATE           NORMAL
    The query uses all records in the CREDIT_CARD_PYMT_DTLS table. Transaction type will be either 'C' or '.

    CREDIT_CARD_PYMT_DTLS has 2 million lines and the qury will display 1.5 million lines. Table statisticas are up to date.

    The query takes now almost 5 minutes. Y thaere a way to reduce the time?

    Our DB server has 8 processors and 8 GB of memory. Is it authentic?

    Thanks in advance.

    Published by: user11115924 on April 29, 2009 02:43
    All columns used in the query are already indexed. (Of course, not only for this query.)

    I should not get too hung up the full Table Scan necessarily - Oracle makes a decision, and even with your new index, he still thinks it is the most effective way to recover the data.

    Did you collect statistics on this new index?

    You have created the index with:

    TO_CHAR("STATEMENT_DATE",'MON-RRRR')
    

    Yet, you seem to be just by selecting statement_date in your query: Oracle cannot use the index (according to functions) in this case!

    If you have only a small number of columns in this table, you can consider an Table of Index organized (ITO), then the table itself is a clue.

    I'd be more inclined to optimize the complete analysis of the table and the creation of other clues, I would say, have you tried the PARALLEL tip?

Maybe you are looking for

  • Sync freezes

    Trying to sync my iPad with my iMac, the synchronization process cannot go beyond the step, "import pictures". I have a few pictures of three selected pictures folders to synchronize, and yet the rotating arrow in "import photos" is not always comple

  • How to get factory reset disks for Satellite Pro L40?

    Hi all Ive got someone other Toshiba Satellite Pro L40 attempt to fix, it got a virus, and the best way to solve this problem is to do a factory reset, so I copied all the personal files on DVD and went to do a factory reset, but told me that I need

  • Program returns to the classic theme after the dialog box

    I have several programs c ++ which works very well under Vista (Basic or is this Aero mode?).  If a dialog box is in the main program and then closed, the theme of the window window main classic Exchange just after the window is moved/size/minimized

  • No its 5515 acer with windows vista

    I was not ressemelable aqble this question if some has solution please pass meThank you

  • Play videos Youtube Webworks

    Hi developer team Webworks I would like to ask how to read the youtube video on webworks app? I try this way html file Object width = "200" height = "150" style = "" border: dotted 1px white ' type = ' application/x-shockwave-flash' "data ="http://ww