Help of query output: display self-referential table

Hello

I'm trying to display a table referring to itself in a cfoutput. I'll start by showing some of the data in the table.

There are only 3 columns, pl_id (auto increment id pri - keys), pl_name and pl_parent_id (0 if it is a parent, otherwise it is the value of pl_id for the parent).

pl_id pl_name pl_parent_id
1 country 0
Food 2 0
3. WE 1
4 Japan 1
5 Burger 2
6 Idaho 3
Florida 7 3
8 cheese 2

What I am trying to output is something like this:
Country - United States - Idaho (3 levels here) or
Country - United States - Florida (or if there are only 2 levels as the following line)
Food - cheese

I tried using a cfoutput with a cfloop as well as grouping but does not have a chance. Could someone clear my head on this one?

Thank you very much

Joe

PS. Adobe should really use a police fixed-width for these forums, it is impossible to align the table info!

Well Yes, who do. After you have changed a little this puppy will be completed. Thanks to the people who reduced to chips in this thread.

Tags: ColdFusion

Similar Questions

  • query to display data in table with several detail table

    Hi all

    I have a few cases with a table header that have more than 3 table of detail, and I have to generate the query to show all the data horizontally.

    tblHdr have column A (PK)

    tblDtl1 have column A (FK), B (PK)

    tblDtl2 have column A (FK), C (PK)

    tblDtl3 have column A (FK), D (PK)

    and I need a query to display data like this:

    AB1C3D1
    AB2C4D2
    AC5D3
    AC6

    all the Details of the table should display data based on the relationship of tblHdr (A).

    tblDtl1 have only 2 rows of data for the FK A

    tblDtl2 just for FK 4 lines of data

    tblDtl3 only 3 lines of data for the FK A

    Another example:

    AB1C1D1
    AB2C2
    A

    B3

    tblDtl1 only 3 lines of data for the FK A

    tblDtl2 have only 2 rows of data for the FK A

    tblDtl3 have only 1 rows of data for the FK A

    Please shed some light. for the record, I'll use this query in ADF, so I'll put using PLSQL in second priority.  I prefer to do it in the SQL query.

    Thank you

    Here are 3 ways. First test of data:

    drop table ta purge;
    create table ta as
    SELECT 'A' AS A FROM dual
    union all
    select 'B' from dual;
    
    drop table tb purge;
    create table tb as
    SELECT 'A' AS A, 'B1' AS B FROM dual
    UNION ALL
    SELECT 'A', 'B2' FROM dual ;
    
    drop table tc purge;
    create table tc as
    SELECT 'A' AS A, 'C1' AS C FROM dual
    UNION ALL
    SELECT 'A', 'C2' FROM dual
    UNION ALL
    SELECT 'A', 'C3' FROM dual
    UNION ALL
    SELECT 'A', 'C4' FROM dual ;
    
    drop table td purge;
    create table td as
    SELECT 'A' AS A, 'D1' AS D FROM dual
    UNION ALL
    SELECT 'A', 'D2' FROM dual
    UNION ALL
    SELECT 'A', 'D3' FROM dual;
    

    Now 3 solutions: full join, group by and pivot:

    with b as (
      select a, b,
      row_number() over(partition by a order by b) rn
      from tb
    )
    , c as (
      select a, c,
      row_number() over(partition by a order by c) rn
      from tc
    )
    , d as (
      select a, d,
      row_number() over(partition by a order by d) rn
      from td
    )
    select a, b, c, d
    from ta left join b using(a)
    full join c using(a, rn)
    full join d using(a, rn)
    order by a, rn;
    
    select a, max(b) b, max(c) c, max(d) d
    from (
      select a, null b, null c, null d, 1 rn
      from ta
      union all
      select a, b, null, null,
      row_number() over(partition by a order by b) rn
      from tb
      union all
      select a, null, c, null,
      row_number() over(partition by a order by c) rn
      from tc
      union all
      select a, null, null, d,
      row_number() over(partition by a order by d) rn
      from td
    )
    group by a, rn
    order by a, rn;
    
    select A,B,C,D from (
      select 'A' tab, a, null val, 1 rn from ta
      union all
      select 'B' tab, a, b,
      row_number() over(partition by a order by b) rn
      from tb
      union all
      select 'C' tab, a, c,
      row_number() over(partition by a order by c) rn
      from tc
      union all
      select 'D' tab, a, d,
      row_number() over(partition by a order by d) rn
      from td
    )
    pivot(max(val) for tab in('B' B, 'C' C, 'D' D))
    order by a, rn;
    
    A B C D
    A B1 C1 D1
    A B2 C2 D2
    A C3 D3
    A C4
    B

    Personally, I would prefer to view the data by using a 'join the union', in order to avoid the impression that the different detail records are related somehow.

    select ta.a, b, c, d
    from tb full join tc on 1=0
    full join td on 1=0
    right join ta on ta.a in (tb.a, tc.a, td.a);
    
    A B C D
    A B1
    A B2
    A C1
    A C2
    A C3
    A C4
    A D1
    A D2
    A D3
    B
  • Need help for query flat_file type clobdata oracle table data.

    Hi Sir,

    I need help to query oracle table flat file data having given clob type.
    Oracle Version:
    
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    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
    
    
    
    Source table
    
      CREATE TABLE order_details 
       (     QUEUE_SEQNUM NUMBER(10,0) NOT NULL ENABLE, 
         LINE_SEQNUM NUMBER(10,0) NOT NULL ENABLE, 
         CHAR_DATA CLOB, 
         OPTIMISTIC_LOCK_KEY NUMBER(20,0)
       ) 
    COLUMN FOR CHAR_DATA FLAT_FILE
    EU,6067AT,AT10,000000402004,NexiumGERDManagementProject,Z435,,ZZ29,NIS-GOLD,AT
    EU,6067AT,AT10,000000402038,NIS-OEU-ARI-2007/1,Z450,,ZZ29,NIS-OEU-ARI-2007/1,AT
    EU,6067AT,AT10,000000402039,SymbicortNISinCOPD,Z450,,ZZ29,NIS-REU-DUM-2007/1,AT
    EU,6067AT,AT10,000000402040,D1443L00044SeroquelXRRuby,Z450,,ZZ29,D1443L00044,AT
    EU,6067AT,AT10,000000402041,NIS-GEU-DUM-2008/1,Z450,,ZZ29,NIS-GEU-DUM-2008/1,AT
    EU,6067AT,AT10,000000402042,SonstigeAktivitätenLCM,Z450,,ZZ29,.,AT
    EU,6067AT,AT10,000000402134,D1680L00002Saxagliptin,Z450,,ZZ29,D1680L00002,AT
    EU,6067AT,AT10,000000402199,SeroquelWaveNIS,Z450,,ZZ29,NIS-NEU-DUM-2009/1,AT
    EU,6067AT,AT10,000000402313,SeroquelExtra(D1443L00082),Z450,,ZZ29,D1443L00082,AT
    EU,6067AT,AT10,000000402517,AtlanticD5130L00006(AZD6140),Z450,,ZZ29,D5130L00006,AT
    EU,6067AT,AT10,000000554494,ArimidexSt.Gallen(13+2),Z142,,ZZ09,,AT
    EU,6067AT,AT10,000000554495,ArimidexASCO(5delegates),Z142,,ZZ09,,AT
    EU,6067AT,AT10,000000554496,ArimidexSanAntonio6delegates,Z142,,ZZ09,,AT
    EU,6067AT,AT10,000000554497,ArimidexBreastCancerSummit(13+2),Z130,,ZZ09,,AT
    EU,6067AT,AT10,000000554498,ArimidexEIH(15delegates),Z130,,ZZ09,,AT
    EU,6067AT,AT10,000000554499,ArimidexNIFA(200delegates),Z135,,ZZ09,,AT
    EU,6067AT,AT10,000000554500,ArimidexNIFAworkshops(8x25),Z135,,ZZ09,,AT
    EU,6067AT,AT10,000000554501,ArimidexPraktischeGyn.Fortbildung,Z147,,ZZ09,,AT
    EU,6067AT,AT10,000000554502,ArimidexAGO,Z147,,ZZ09,,AT
    EU,6067AT,AT10,000000554503,ArimidexHämato/OnkologieKongress,Z147,,ZZ09,,AT
    EU,6067AT,AT10,000000554504,ARIMIDEXGYNäKOLOGENKONGRESS,Z147,,ZZ09,,AT
    EU,6067AT,AT10,000000554505,ArimidexChirurgenkongress,Z147,,ZZ09,,AT
    EXPECTED RESULTS:
    AFFIRM_CODE COMPANY_CODE INTERNAL_ORDER_CODE INTERNAL_ORDER_DESC ENIGMA_ACTIVITY             SUB_ACTIVITY_CODE IN_AFF_IND ORDER_TYPE EXTERNAL_ORDER COUNTRY        
    EU          6067AT       AT10                 000000402004       NEXIUMGERDMANAGEMENTPROJECT     Z435           NULL        ZZ29       NIS-GOLD        AT             
    EU          6068AT       AT11                 000000402005       NEXIUMGERDMANAGEMENTPROJECT     Z435           NULL        ZZ29       NIS-GOLD        AT             

    Sorry, my bad. Without database at hand, I'll try 'baby steps' (borrowed from Frank) so you don't confuse it with errors that I might add (happens far too often already, but at least you won't "swallow" as forum members think is one of the main goals of this fighter - help her learn - providing not only the proverbial fish.)
    Search the Forum - your problem is one of its best sellers. Watching {message identifier: = 10694602} ("split string into" was the key word used in research) you can try something as

    select table_row,
           level clob_row,
           regexp_substr(char_data,'[^' || chr(13) || chr(10) || ']+',1,level) the_line
      from (select to_char(queue_seqnum)||':'||to_char(line_seqnum) table_row,
                   char_data
              from order_details
           )
     connect by regexp_substr(char_data,'[^' || chr(13) || chr(10) || ']+',1,level) is not null
            and prior char_data = char_data
            and prior table_row = table_row
            and prior sys_guid() is not null
    

    to get all the s the_lineall CLOB and after that the use of the example even to get your columns of each the_line.

    Concerning

    Etbin

    Edited by: Etbin on 3.2.2013 09:01

    .. .but I m connected to do things according to the instructions, I can't do something.

    Used to happen to me too and I did as told to the but only after explaining any disadvantages, I was aware of in time. The last sentence is usually: "O.K. now be just and Don't come back with that kind of thing when it turns out that this isn't the right thing."
    rp0428 post - something to remember.

  • Need help with query outputing group names

    I'm trying to find a way for groups of output headers, then all the records in each group etc header. It would be easy, except there is a key with what I want to do.

    Normally, if I have this data set (that I've ' borrowed' a site that showed the closest to what I was looking for):

    Example table:

    TABLE [number]

    (Name, NUMBER)

    Dave Bower 843-444-4444

    Dave Bower 843-555-5555

    Matthew Small 843-111-1111

    Matthew Small _843-222-2222

    Matthew Small 843-333-3333

    I could use the following code:

    < cfoutput query = "somequery" group = "name" >

    #name # < br >

    < cfoutput >

    #phonenumber # < br >

    < / cfoutput >

    < hr >

    < / cfoutput >

    And get this:

    Dave Bower

    843-444-4444.

    843-555-5555.

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

    Matthew Small

    843-111-1111.

    843-222-2222.

    843-333-3333.

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

    BUT my actual tables are not set up like that. Rather than recording of every name of every record, I would have an ID that is the foreign key to another table.

    Current table set up is as follows:

    TABLE [people]

    (ID, NAME)

    1 Dave Bower

    2 small Matthew

    TABLE [Phones]

    (PEOPLE_ID NUMBER)

    1 843-444-4444

    1 843-555-5555

    2 843-111-1111

    2 843-222-2222

    2 843-333-3333

    If this output actually would this give me with my current setup and request above code:

    1

    843-444-4444.

    843-555-5555.

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

    2

    843-111-1111.

    843-222-2222.

    843-333-3333.

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

    How can I keep my current setup but create a query that produces the same result from the top? (The table names of people like the group headers, but data from the phones table under that output)

    You must gather the two tables, and then group the output.

    Something along the lines of the (may vary slightly depending on your DB and the exact table structure)

    SELECT ppl.name, ph.number

    PEOPLE ppl

    INNER JOIN phones ph ON ppl.id = ph.people_id

    ORDER BY ppl.name

    See you soon

    Kai

  • Help of query output

    Oracle 11.2.0.1

    Windows

    create the table storetab

    (

    deptName varchar2 (20).

    grpcode varchar2 (10),

    grpname varchar2 (10),

    ItemName varchar2 (10),

    Plug varchar2 (10),

    number of quantity,

    number of rates,

    number amount

    );

    insert into storetab values ('KEEP', 'GRP1', 'GRP1', 'ITEM1', ", 0,0,0);

    insert into storetab values ('KEEP', 'GRP2', 'GRP2', 'ITEM2', ", 0,0,0);

    insert into storetab values ('KEEP', 'GRP3', 'GRP1', 'ITEM3' ", 0,0,0);

    insert into storetab values ('BUY', 'GRP7', 'GRP9', 'ITEM6' ", 0,0,0);

    insert into storetab values ('SALE', 'ACM2', 'GRP3', 'ITEM4' ", 0,0,0);

    insert into storetab values ('SALE', 'ACM5', 'GRP6', 'ITEM5' ", 0,0,0);

    insert into storetab values ('SALE', 'QOW2', 'GRP3', 'ITEM7' ", 0,0,0);

    insert into storetab values ('KEEP', 'IDS9', 'GRP10', 'ITEM1', ", 0,0,0);

    insert into storetab values ('KEEP', 'KKZ0', 'GRP2', 'ITEM6' ", 0,0,0);

    insert into storetab values ('ACCOUNTS', 'GRP3', 'GRP23', 'ITEM4' ", 0,0,0);

    insert into storetab values ('IT', 'PQM7', 'GRP221', 'ITEM2', ", 0,0,0);

    insert into storetab values ('IT', 'GRP1', 'GRP32', 'ITEM3' ", 0,0,0);

    insert into storetab values ('IT', 'PQM3', 'GRP1', 'ITEM5' ", 0,0,0);

    Select * from storetab;

    GRPCODE DEPTNAME GRPNAME ITEMNAME QTY FORM THE RATE AMOUNT

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

    STORE                GRP1      GRP1      ITEM1                                                    0    0          0

    STORE                GRP2      GRP2      ITEM2                                                    0    0          0

    STORE                GRP3      GRP1      ITEM3                                                    0    0          0

    PURCHASE GRP7 GRP9 ITEM6 0 0 0

    SALES                ACM2      GRP3      ITEM4                                                    0    0          0

    SALES                ACM5      GRP6      ITEM5                                                    0    0          0

    SALES                QOW2      GRP3      ITEM7                                                    0    0          0

    STORE                IDS9      GRP10      ITEM1                                                    0    0          0

    STORE                KKZ0      GRP2      ITEM6                                                    0    0          0

    ACCOUNTS GRP23 ITEM4 GRP3 0 0 0

    IT                  PQM7      GRP221    ITEM2                                                    0    0          0

    GRPCODE DEPTNAME GRPNAME ITEMNAME QTY FORM THE RATE AMOUNT

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

    IT                  GRP1      GRP32      ITEM3                                                    0    0          0

    IT                  PQM3      GRP1      ITEM5                                                    0    0          0

    13 selected lines.

    Power required:

    GRPCODE          GRPNAME          ITEMNAME     SPECS     QTY     RATE     AMOUNT
    ACCOUNTS--->GRP3          GRP23          ITEM4
    IT--->PQM7          GRP221          ITEM2
    GRP1          GRP32          ITEM3
    PQM3          GRP1          ITEM5
    PURCHASE--->GRP7          GRP9          ITEM6
    SALES--->ACM2          GRP3          ITEM4
    ACM5          GRP6          ITEM5
    QOW2          GRP3          ITEM7
    STORE--->GRP1          GRP1          ITEM1          
    GRP2          GRP2          ITEM2     
    GRP3          GRP1          ITEM3
    IDS9          GRP10          ITEM1
    KKZ0          GRP2          ITEM6
    

    Thank you.

    SQL > select grpcode
    2, grpname
    3, itemname
    4, plug
    5, Qty
    6, rate
    7, amount
    8 of storetab
    model 9
    10 partition by (deptname)
    dimension 11 by (row_number() on NWR (partition by deptname order grpcode))
    12 measures (cast (grpcode as varchar2 (50)) grpcode, grpname, itemname, dname, deptname, qty, rate, amount)
    13 rules upsert
    (14)
    15 grpcode [0] = dname [1] | '----->'
    16)
    Order 17
    18 by deptname
    19, NWR;

    GRPCODE GRPNAME ITEMNAME QTY CHARGE RATE CARD
    ------------------------- ---------- ---------- ---------- ---------- ---------- ----------
    ACCOUNTS--->
    GRP3                      GRP23      ITEM4                          0          0          0
    IT--->
    GRP1                      GRP32      ITEM3                          0          0          0
    PQM3                      GRP1       ITEM5                          0          0          0
    PQM7                      GRP221     ITEM2                          0          0          0
    PURCHASE--->
    GRP7                      GRP9       ITEM6                          0          0          0
    SALES--->
    ACM2                      GRP3       ITEM4                          0          0          0
    ACM5                      GRP6       ITEM5                          0          0          0
    QOW2                      GRP3       ITEM7                          0          0          0
    STORE--->
    GRP1                      GRP1       ITEM1                          0          0          0
    GRP2                      GRP2       ITEM2                          0          0          0
    GRP3                      GRP1       ITEM3                          0          0          0
    IDS9                      GRP10      ITEM1                          0          0          0
    KKZ0                      GRP2       ITEM6                          0          0          0

    18 selected lines.

    SQL >

  • Select root hierarchical self-referential table record

    Hello

    is there a quick way to select the folder in root of any given ID?
    with t as (
      select 1 as PID, null as PARENTID, 'Root 1' as DESCRIPTION from dual union all
      select 2,1,'Sub 1.1' from dual union all
      select 3,1,'Sub 1.2' from dual union all
      select 4,null,'Root 2' from dual union all
      select 5,4,'Sub 2.1' from dual union all
      select 6,5,'Sub 2.11' from dual
    )
    select 
      ???
    from 
      t
    where 
      t.PID = 6;
    SQL> with t as (
      2    select 1 as PID, null as PARENTID, 'Root 1' as DESCRIPTION from dual union all
      3    select 2,1,'Sub 1.1' from dual union all
      4    select 3,1,'Sub 1.2' from dual union all
      5    select 4,null,'Root 2' from dual union all
      6    select 5,4,'Sub 2.1' from dual union all
      7    select 6,5,'Sub 2.11' from dual
      8  )
      9  select pid , CONNECT_BY_ROOT pid root_node
     10    from t
     11  where pid = &a
     12  start with parentid is null
     13  connect by prior pid = parentid
     14  /
    Enter value for a: 6
    old  11: where pid = &a
    new  11: where pid = 6
    
           PID  ROOT_NODE
    ---------- ----------
             6          4
    
    SQL> /
    Enter value for a: 5
    old  11: where pid = &a
    new  11: where pid = 5
    
           PID  ROOT_NODE
    ---------- ----------
             5          4
    
    SQL> /
    Enter value for a: 3
    old  11: where pid = &a
    new  11: where pid = 3
    
           PID  ROOT_NODE
    ---------- ----------
             3          1
    
    SQL> /
    Enter value for a: 2
    old  11: where pid = &a
    new  11: where pid = 2
    
           PID  ROOT_NODE
    ---------- ----------
             2          1
    
    SQL> /
    Enter value for a: 1
    old  11: where pid = &a
    new  11: where pid = 1
    
           PID  ROOT_NODE
    ---------- ----------
             1          1
    

    Published by: Karthick_Arp on January 20, 2009 04:39

  • need help hard query

    Hello

    I'm trying to find out who is the manager who have more number of carried forward under him of emp table

    can you please help me how to find... I searched the forum and I tried some queries but does not work...

    Thank you

    ASP.

    Hello

    You need to display the results of the sample such that people who want to help you can recreate the problem and test their ideas.  Do you think that people can run what you posted?  You must post CREATE TABLE and INSERT statements or equivalent SB.

    Once more, if you use a commonly available table, for example scott.emp, just say.

    Explain how you get these results.  For example, "when I say 'Manager', I mean the employee identified in the mgr column; It does not matter if job = 'MANAGER' or not.  In this issue, I'm only interested in direct subordinates.  For example, the KING (empno = 7839) is Manager, directly or indirectly, the other 13 lines in the table, but only 3 of these lines have mgr = 7839.  There are 5 lines having mgr = 7698 (for BLAKE), so I want BLAKE rather than KING. »

    Here's a way to do it:

    WITH got_rnk AS

    (

    SELECT m.empno, m.ename, m.job - or other columns of your choice

    EARL of (e.mgr) AS reportee_count

    , EVALUATE () OVER (ORDER OF COUNT (*) / / DESC) AS rnk

    FROM scott.emp m

    LEFT OUTER JOIN scott.emp e ON e.mgr = m.empno

    GROUP OF m.empno, m.ename, m.job

    )

    SELECT reportee_count, empno, ename

    OF got_rnk

    WHERE rnk = 1

    ;

    Exit from scott.emp (in the case that is different from what you have posted);

    EMPNO, ENAME, JOB REPORTEE_COUNT

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

    7698 BLAKE MANAGER 5

    If there be a tie for the line with the majority of direct reports, the above query will display all the contenders.

  • Need help with query to get days of work there are using the calendar BOM

    RDBMS: 10.2.0.4.0
    Oracle Applications: 11.5.10.2

    I try to use the BOM existing in the EBS to calculate working days calendar, there is a report that I am train. The BOM calendar presents the working days and non-working with the weekend days and holidays listed as non-working days. The following query gives correct results, but I'm looking for two different ways to do the same without "the union. I have nothing against the "unions", but I feel that I'm missing a more elegant to get there way. The query will in Discoverer Plus 10.1.2.3, so using a statement 'By' is not supported.
    sample data
    
    calendar_code                calendar_date                 seq_num                     
    SAC-WRKDAY                   12/3/2010                     1817
    SAC-WRKDAY                   12/4/2010                                                              
    SAC-WRKDAY                   12/5/2010                                                              
    SAC-WRKDAY                   12/6/2010                     1818                                 
    SAC-WRKDAY                   12/7/2010                     1819                                 
    SAC-WRKDAY                   12/8/2010                     1820     
    SAC-WRKDAY                   12/9/2010                     1821
    SAC-WRKDAY                   12/10/2010                    1822
    SAC-WRKDAY                   12/11/2010                   
    SAC-WRKDAY                   12/12/2010
    SAC-WRKDAY                   12/13/2010                    1823             
    select calendar_code
         , calendar_date
         , seq_num
         , sum(decode(bcd.seq_num,null,0,1))over(partition by bcd.calendar_code order by bcd.calendar_date desc) workdays_ago
    from   bom.bom_calendar_dates bcd
    where  calendar_code = 'SAC-WRKDAY'     
    and    trunc(bcd.calendar_date) < trunc(sysdate)
    
    union
    
    select calendar_code
         , calendar_date
         , seq_num
         , -sum(decode(bcd.seq_num,null,0,1))over(partition by bcd.calendar_code order by bcd.calendar_date ) workdays_ago
    from   bom.bom_calendar_dates bcd
    where  calendar_code = 'SAC-WRKDAY'
    and    trunc(bcd.calendar_date) > trunc(sysdate)
    sample output
    
    calendar_code                calendar_date                 seq_num                      workdays_ago
    SAC-WRKDAY                   12/3/2010                     1817                                  3
    SAC-WRKDAY                   12/4/2010                                                           2
    SAC-WRKDAY                   12/5/2010                                                           2
    SAC-WRKDAY                   12/6/2010                     1818                                  2
    SAC-WRKDAY                   12/7/2010                     1819                                  1
    SAC-WRKDAY                   12/9/2010                     1821                                 -1
    SAC-WRKDAY                   12/10/2010                    1822                                 -2
    SAC-WRKDAY                   12/11/2010                                                         -2
    SAC-WRKDAY                   12/12/2010                                                         -2
    SAC-WRKDAY                   12/13/2010                    1823                                 -3

    Hello

    Of course, you should be able to combine these queries, something like this:

    select calendar_code
         , calendar_date
         , seq_num
         , sum ( CASE
               WHEN  bcd.seq_num IS NULL
               THEN  0
               WHEN  bcd.calendar_date < TRUNC (SYSDATE)
               THEN  1
               ELSE  -1
              END
            ) over ( partition by  bcd.calendar_code
                  ,            SIGN (SYSDATE - bcd.calendar_date)
                  order by        ABS  (SYSDATE - bcd.calendar_date)
                ) workdays_ago
    from   bom.bom_calendar_dates bcd
    where  calendar_code = 'SAC-WRKDAY'
    and    trunc(bcd.calendar_date) < trunc(sysdate)
    

    If you do not want to display some CREATE TABLE and INSERT statements for the sample data, and then I could test it.

    t_norwillo wrote:
    ... I have nothing against the "unions", but I feel that I'm missing a more elegant to get there way.

    Good thinking!
    When the two branches of the UNION query the same table, there is usually a more effective way: something that only requires a pass through the table.

  • I get this message when you try to play a dvd - Windows Media Player cannot play this DVD because it is not possible to activate the analog copy on the output display protection.

    I bought a DVD called "The Secret" and I can't play.

    And I get this message
    Windows Media Player cannot play this DVD because it is not possible to activate the analog copy on the output display protection. Try to install a driver available for your video card.

    Hello

    Thanks for asking!

    1. have there been recent changes to the system before the show?

    2 is confined to a specific DVD?

    3. What is the file format of the DVD?

    Method 1:

    Follow the link and follow the steps. Check if it helps.

    Windows Media Player cannot play this DVD because it is not possible to activate the analog copy on the output display protection

    http://support.Microsoft.com/kb/2004673

    http://www.Microsoft.com/windows/windowsmedia/player/Webhelp/default.aspx?&mpver=12.0.7100.0&ID=C00D1167&ContextId=61&OriginalID=C00D1167

    Method 2:

    Follow the link and update drivers display, check if it helps.

    http://Windows.Microsoft.com/en-in/Windows7/update-a-driver-for-hardware-that-isn ' t-work correctly

    Answer with the results, I'd be happy to help you best.

  • SQL query to display the sum of the values of each June and December

    Hello having problems of construction of a query to the list SQL query to display the sum of the values of each June and December each year.

    My Table;

    TABLE name: MONTH_TERM

    Fields with values:

    TERM_KEYMONTH_ACTUALMONTH_DATE
    8250001/11/2015 0:00
    8245001/12/2015 0:00
    8240501/01/2016 0:00
    8240001/02/2016 0:00
    8245001/03/2016 0:00
    8242501/04/2016 0:00
    8243501/05/2016 0:00
    8241006/01/2016 0:00
    8240901/07/2016 0:00
    8241501/08/2016 0:00
    8242009/01/2016 0:00
    8242210/01/2016 0:00
    8243611/01/2016 0:00
    8255601/12/2016 0:00
    8256801/01/2017 0:00
    8262402/01/2017 0:00

    What I would like to see in a query result:

    TERM_KEYMONTH_ACTUALMONTH_DATETotal of 6 months
    8250001/11/2015 0:00
    8245001/12/2015 0:00950
    8240501/01/2016 0:00
    8240001/02/2016 0:00
    8245001/03/2016 0:00
    8242501/04/2016 0:00
    8243501/05/2016 0:00
    8241006/01/2016 0:002525
    8240901/07/2016 0:00
    8241501/08/2016 0:00
    8242009/01/2016 0:00
    8242210/01/2016 0:00
    8243611/01/2016 0:00
    8255601/12/2016 0:002658
    8256801/01/2017 0:00
    8262402/01/2017 0:00

    ---

    Here's my query:

    Select

    "TERM_KEY,"

    "MONTH_ACTUAL,"

    to_char(MONTH_DATE,'MM/YYYY') MONTH_DATE,

    DEAL to_char (MONTH_DATE, 'MM')

    WHEN '06' THEN (SELECT SUM (MONTH_ACTUAL)

    OF MONTH_TERM

    WHERE the to_char (MONTH_DATE, 'MM') between 1 and 6

    AND term_key = 82)

    WHEN '12' THEN (SELECT SUM (MONTH_ACTUAL)

    OF MONTH_TERM

    WHERE the to_char (MONTH_DATE, 'MM') between 7 and 12

    AND term_key = 82)

    ELSE null

    END as SIX_MO_CUMM,

    of MONTH_TERM

    where term_key = 82

    It's my results:

    TERM_KEYMONTH_ACTUALMONTH_DATETotal of 6 months
    8250001/11/15 0:00
    8245001/12/15 0:003608
    8240501/01/16 0:00
    8240001/02/16 0:00
    8245001/03/16 0:00
    8242501/04/16 0:00
    8243501/05/16 0:00
    8241001/06/16 0:003717
    8240901/07/16 0:00
    8241501/08/16 0:00
    8242001/09/16 0:00
    8242210/01/16 0:00
    8243601/11/16 0:00
    8255601/12/16 0:003608
    8256801/01/17 0:00
    8262401/02/17 0:00

    Any ideas on how to fix would be great

    Select term_key,

    month_actual,

    month_date,

    case mod (to_char (month_date, 'mm'), 6)

    When 0 then sum (month_actual)

    During)

    term_key partition

    order of month_date

    between the previous month '5' interval and the current line

    )

    end '6 MONTHS in TOTAL'

    from tbl

    order of term_key,

    month_date

    /

    TERM_KEY MONTH_ACTUAL MONTH_DAT 6 MONTHS TOTAL
    ---------- ------------ --------- --------------
    82 500 NOVEMBER 1ST, 15TH
    82 450 1 DECEMBER 15 950
    82 405 1 JANUARY 16
    82 400 1 FEBRUARY 16
    82 450 1ST MARCH 16
    82 425 1ST APRIL 16
    82 435 1 MAY 16
    82 410 2525 1 JUNE 16
    82 409 1 JULY 16
    82 415 1ST AUGUST 16
    82 420 16 - SEP - 01

    TERM_KEY MONTH_ACTUAL MONTH_DAT 6 MONTHS TOTAL
    ---------- ------------ --------- --------------
    82 422 1 OCTOBER 16
    82-436 NOVEMBER 1, 16
    82 556 2658 1 DECEMBER 16
    82 568 1 JANUARY 17
    82 624 1 FEBRUARY 17

    16 selected lines.

    SQL >

    SY.

  • Is it possible output display of list of items in web app using two categories?

    Help, please! Is it possible output display of list of items in web app using two categories? For example, I want to list all the items web app 32098 marked with categories 189076 AND 190266, excluding items that have been marked with one of these categories. Site is not currently liquid activated, but I could enable, if necessary. Any suggestion would be appreciated.

    I highly recommend the App search Web use if you ever want to search by multiple fields.

    I recommend against the use of categories. Avoid as much as possible, categorization items if you can. Try to work on your web applications around the areas of web application development and web app datasource, if you can.

    This allows you to easily filter a web application defined by one or more fields with precision and fast!

    Here is an example of a site using web app search find a floor - Tauranga carpets and floor coverings

    Here's another example of site Web too: our range of rolls of carpet

    However, if you insist and require the use of categorize, I know to categorize, you can have 1-to-many relationships, so I think that Robert Bell said that it the best, you can simply filter web app items from several categories. Even if using liquid - by the way, as output of fluid tell you not what the element is qualified.

    My recommendation is to rethink your application web, if possible, do not use categories.

    Hope this helps,

    Stephen

  • Catalog cannot be displayed in a table element? Is it possible to do them in a format similar to an unordered products list unordered list?

    Hello to the BC community,

    As indicated above, catalog cannot be displayed in a table element? Is it possible to do them in a format similar to an unordered products list unordered list? Overall, I'm looking to create a sensitive site and I like what the general store looks like, I just want to set the flow of catalogue items as I can with products. List items would be great for a catalog item, but I can't seem to locate it in the documentation that comes with BC. I could be completely missing it and if I did, I'm sorry! Thanks in advance for any help I can get with this topic!

    You just need to change the options of the tags - the Developer Reference
    This is the last parameter of the tag.

  • Insert a blank line in the query output

    Is it possible to insert a blank line between two rows of the query output?

    In the EMP table, the column LINES is as follows:

    LINES
    1
    2
    3
    4
    1
    2
    3
    1
    2
    3
    4
    5

    I want to insert a blank line after every 1

    Please suggest.

    Sanjay

    I'm quite puzzled why you need rows in the dataset returned by a select statement that is empty.
    If you are using Oracle reports to the release date, you define the presentation of the report to have spaces between the rows returned by the select and have do not need to have the select statement returns a blank line after each line of data. If the output should be obtained by using another client, I think that the customer will have facilities for output formatting.

    Admit that you really need "blank lines" between data lines, I see only one way: use a temporary table and do an insert into select temporary_table (...) ... from... where... Then, in this temporary table, you can insert 'empty rows', which is actually not really empty, because they must have some fields that give the order of the rows. And then select in temporary_table, you place your order by the columns that are used to give the order for the release.
    Thus

    insert into temporary_table (
    ....
    )
    select ...
    from ...
    where ...
    ;
    for r in (
    select col1, col2, col3  -- columns used for order by
    from temporary_table
    order by col1, col2, col3
    )
    loop
      insert into temporary_table (col1, col2,col3, col4)
      values (r.col1,r.col2,r.col3, null);
    end loop;
    -- this way, a select * from temporary_tabel order by col1, col2, col3, col4 will return a blank row after each data row
    
  • How do I get the output of a function table

    Hi all

    Kindly share your idea.


    I need the outputs of a function table only.

    Database version: oracle 10.1.0.2.0

    login_details:

    login_id branch_code

    admin 1
    Admin1 2
    Test 1
    user 1

    I need output for the query function below.

    Select login_id from login_details where branch_code = '1';

    If I create a function:


    FUNCTION to CREATE or REPLACE fn_get_login (pvBranch varchar2)
    IS BACK SYS_REFCURSOR
    REF_TEST SYS_REFCURSOR;
    BEGIN
    OPEN FOR REF_TEST
    Login_id SELECT FROM login_details WHERE branch_code = pvBranch;
    RETURN REF_TEST;

    END;
    /


    Select * from login_master where login_id in (select fn_get_login('01') from double);


    and get

    ORA-00932: inconsistent data types: expected - got CURSER

    Edited by: 887268 October 8, 2012 12:25

    You cannot use a Ref cursor in a table, because it isn't a result set of data, it's just a pointer to a request for enforcement.

    {: identifier of the thread = 886365}

    A ref cursor must be used if you want to refer the request to an external application.

    Transfer data back to a function is to use a pipeline for example function

    SQL> CREATE OR REPLACE TYPE num_descript AS OBJECT(num number, descript varchar2(30))
      2  /
    
    Type created.
    
    SQL>
    SQL> CREATE OR REPLACE TYPE tbl_num_descript AS TABLE OF num_descript
      2  /
    
    Type created.
    
    SQL>
    SQL>
    SQL> CREATE OR REPLACE PACKAGE reftest AS
      2    FUNCTION pipedata(p_choice number) RETURN tbl_num_descript PIPELINED;
      3  END;
      4  /
    
    Package created.
    
    SQL>
    SQL> CREATE OR REPLACE PACKAGE BODY reftest AS
      2    FUNCTION pipedata(p_choice number) RETURN tbl_num_descript PIPELINED IS
      3      v_obj num_descript := num_descript(NULL,NULL);
      4      v_rc  sys_refcursor;
      5    BEGIN
      6      IF p_choice = 1 THEN
      7        OPEN v_rc FOR SELECT empno as num, ename as descript FROM emp;
      8      ELSIF p_choice = 2 THEN
      9        OPEN v_rc FOR SELECT deptno as num, dname as descript FROM dept;
     10      END IF;
     11      LOOP
     12        FETCH v_rc INTO v_obj.num, v_obj.descript;
     13        EXIT WHEN v_rc%NOTFOUND;
     14        PIPE ROW(v_obj);
     15      END LOOP;
     16      CLOSE v_rc;
     17      RETURN;
     18    END;
     19  END;
     20  /
    
    Package body created.
    
    SQL> select * from table(reftest.pipedata(1));
    
           NUM DESCRIPT
    ---------- ------------------------------
          7369 SMITH
          7499 ALLEN
          7521 WARD
          7566 JONES
          7654 MARTIN
          7698 BLAKE
          7782 CLARK
          7788 SCOTT
          7839 KING
          7844 TURNER
          7876 ADAMS
          7900 JAMES
          7902 FORD
          7934 MILLER
    
    14 rows selected.
    
    SQL> select * from table(reftest.pipedata(2));
    
           NUM DESCRIPT
    ---------- ------------------------------
            10 ACCOUNTING
            20 RESEARCH
            30 SALES
            40 OPERATIONS
    
    SQL>
    

    but of course, it is wise to just use pure SQL that in order to mix the PL/SQL in queries in the form of best performance features.

    Perhaps explain what problem you are trying to solve when trying to use a function, and we can advise you on the best options.

  • MDX query to display parent-child combination

    Hi guys...
    I am really new to Essbase technology.
    Could you please help me with this one:
    is it possible to extract data (for example the metadata of a contour)... for example:-
    The hierarchical structure is as follows:
    A1
    A11
    A12
    A2
    A21
    A22
    I want a MDX query to display as:
    A1 A11
    A12 A1
    A21 A2
    A22 A2
    I tried different ways but could not come up with a request for it.
    Thanks in advance for your help.

    This may mean a wrong path, I performed just following on the server - essbase

    export sample.basic contour all dimensions to xml_file 'c:/temp/outline.xml ';

    See you soon

    John
    http://John-Goodwin.blogspot.com/

Maybe you are looking for