[10g] need help with order by hierarchical query clause

I have the following data samples:
CREATE TABLE     bill_test1
(     parent_part     CHAR(25)
,     child_part     CHAR(25)
,     line_nbr     NUMBER(5)
,     qty_per          NUMBER(9,5)
);

INSERT INTO bill_test1 VALUES ('ABC-1','ABC-10',100,1);
INSERT INTO bill_test1 VALUES ('ABC-1','ABC-20',200,2);
INSERT INTO bill_test1 VALUES ('ABC-1','ABC-30',300,3);
INSERT INTO bill_test1 VALUES ('ABC-1','HARDWARE-1',401,10);
INSERT INTO bill_test1 VALUES ('ABC-1','HARDWARE-2',402,5);
INSERT INTO bill_test1 VALUES ('ABC-10','ABC-155',100,2);
INSERT INTO bill_test1 VALUES ('ABC-10','HARDWARE-1',200,1);
INSERT INTO bill_test1 VALUES ('ABC-155','RAW-2',100,4.8);
INSERT INTO bill_test1 VALUES ('ABC-155','HARDWARE-3',200,3);
INSERT INTO bill_test1 VALUES ('ABC-20','RAW-1',100,10.2);
INSERT INTO bill_test1 VALUES ('ABC-30','RAW-3',100,3);
And the following query gives me exactly what I want, in the order I want. However, I wonder if there is a way to get this order without creating the column SEQ, given that I don't need in my results
SELECT     part_nbr
,     parent_part
,     child_part
FROM     (
     SELECT     CONNECT_BY_ROOT b.parent_part                         AS part_nbr
     ,     b.parent_part
     ,     b.child_part
     ,     SYS_CONNECT_BY_PATH(b.line_nbr,' ')                    AS seq
     FROM     bill_test1 b
     ,     dual
     CONNECT BY     parent_part     = PRIOR child_part
     )
WHERE          part_nbr     = 'ABC-1'
ORDER BY     seq
;

Results of above query, except with SEQ included in SELECT (just to show what I'm sorting off of):
PART_NBR                     PARENT_PART                  CHILD_PART                   SEQ
---------------------------- ---------------------------- ---------------------------- -----------------
ABC-1                        ABC-1                        ABC-10                        100
ABC-1                        ABC-10                       ABC-155                       100 100
ABC-1                        ABC-155                      RAW-2                         100 100 100
ABC-1                        ABC-155                      HARDWARE-3                    100 100 200
ABC-1                        ABC-10                       HARDWARE-1                    100 200
ABC-1                        ABC-1                        ABC-20                        200
ABC-1                        ABC-20                       RAW-1                         200 100
ABC-1                        ABC-1                        ABC-30                        300
ABC-1                        ABC-30                       RAW-3                         300 100
ABC-1                        ABC-1                        HARDWARE-1                    401
ABC-1                        ABC-1                        HARDWARE-2                    402

Hello

As long as there is that a single root, brothers and SŒURS of ORDER BY, you say, but you can not do in a subquery (well, you can, but usually there is no interest in a subquery). If the CONNECT BY in a subquery, there is no guarantee that the main request will preserve the hierarchical order which provides the subquery.

The query you posted does not require a query of Tahina, so you can say:

SELECT     CONNECT_BY_ROOT b.parent_part                         AS part_nbr
,     b.parent_part
,     b.child_part
--,     SYS_CONNECT_BY_PATH(b.line_nbr,' ')                    AS seq
FROM     bill_test1 b
WHERE          CONNECT_BY_ROOT b.parent_part     = 'ABC-1'
CONNECT BY     parent_part     = PRIOR child_part
ORDER SIBLINGS BY     b.line_nbr
;

I said the query you posted does not require a subquery. It also does not require double, so I guess that what you posted is a simplification of what you are really doing, and that could have a subquery. In particular, if you want to GROUP BY part_nbr, you need the subquery. We can use CONNECT_BY_ROOT expression in the WHERE clause (or, come to think of it, use a START WITH clause instead WHERE), but, for some reason, we cannot use CONNECT_BY_ROOT in a clause GROUP BY; We need to calculate CONNECT_BY_ROOT in a subquery, give it a name (like part_nbr) and Super GROUP OF this column in a query.

This requires that there is that one node root. ORDER OF brothers and SŒURS means just that: children of a common parent will appear in the order, but the root nodes, which have no parents, may not be in order.

Here's what I meant by using START WITH place WHERE:

SELECT     CONNECT_BY_ROOT b.parent_part                         AS part_nbr
,     b.parent_part
,     b.child_part
--,     SYS_CONNECT_BY_PATH(b.line_nbr,' ')                    AS seq
FROM     bill_test1 b
START WITH     b.parent_part     = 'ABC-1'
CONNECT BY     parent_part     = PRIOR child_part
ORDER SIBLINGS BY     b.line_nbr
;

This should be much more effective, because it reduces the results before waste you your time by getting their descendants.
With the help of a clause START WITH here is analogous to me sending you an email, saying "come to a meeting one my office at 03:00."
By using a WHERE clause here is similar by sending me an e-mail to all members of society, saying: "come to a meeting one my office at 3:00" and then, as people get here, tell everyone except you could go back.

Brothers and SŒURS ORDER BY was introduced in Oracle 9.

Published by: Frank Kulash, December 9, 2010 14:39
Added version with the START WITH clause

Tags: Database

Similar Questions

  • Need help with ordering high voltage

    Hello

    NI PCIe-6341 card is already installed. And I want to order a power supply voltage (CZE1000R) to generate the high voltage (DC). The goal is to fully control the high voltage. For example, the voltage can chang from zero to 30 kV in 5 or 10 seconds and be stable to 30 kV to 30 minutes and then go down smoothly at 20 kV in 5 minutes and finally back to zero. Could someone help me with this task? Thank you.

    Hi, apok,

    I used the 'panels-test' on 'measurement and automation explorer. And I see signals on an oscilloscope.

    Thank your for your help.

    But when I try to test the "tension cntrl.vi" it has not worked.

    On the manual, he said:

    "

    Programming with external voltage:

    Disconnect between TB1-2 and TB1 - 3 riders. Connect signal 0 - 10V between TB1-3 and TB1-6 (common)".

    This means that I need to plug TB1 - 3 and TB1 - 6 and out of the acronym to TB1-3?

  • Need help with rewrite of a query

    Hi friends,

    PFB the query and the result. Please ignore where the conditions, they are only about 50% accurate.

    SELECT XMLELEMENT ( 'majorLine' XMLATTRIBUTES ( ) d. ) line_id AS "Row Id" ),

    xmlforest (d. ) ordered_item as "itemName" , 

    d . ordered_quantity as 'quantity' ),

    (SELECT XMLAGG (XMLELEMENT ()"Service" XMLATTRIBUTES (e. ))) line_id AS Service ),

    ( ) SELECT XMLAGG (XMLELEMENT ( "ServiceName" ))

    XMLATTRIBUTES (of. ) ordered_item AS "ItemName" ),

    xmlforest (of. ) ordered_item as "itemName" , 

    de . ordered_quantity as 'quantity' )))

    DE oe_order_lines_all of

    de . line_id = e. line_id et de . link_to_line_id is null ))) 

    DE oe_order_lines_all e

    e. line_id = 143424538 ),

    (SELECT XMLAGG (XMLELEMENT ()"minorLine" XMLATTRIBUTES (e. ))) line_id AS minorLine ),

    ( ) SELECT XMLAGG (XMLELEMENT ( "itemName" ))

    XMLATTRIBUTES (of. ) ordered_item AS "ItemName" ),

    xmlforest (of. ) ordered_item as "itemName" , 

    de . ordered_quantity as 'quantity' )))

    DE oe_order_lines_all of

    de . line_id = e. line_id )))

    DE oe_order_lines_all e

    ( e. line_id = 143424538 ), (SELECT XMLAGG (XMLELEMENT ()"service" XMLATTRIBUTES (e. ))) line_id AS Service ),

    ( ) SELECT XMLAGG (XMLELEMENT ( "serviceName" ))

    XMLATTRIBUTES (of. ) ordered_item AS "itemName" ),

    xmlforest (of. ) ordered_item as "itemName" , 

    de . ordered_quantity as 'quantity' )))

    DE oe_order_lines_all of

    de . line_id = e. line_id et de . link_to_line_id is null ))) 

    DE oe_order_lines_all e

    ( e. line_id = 143424538 ( )

    ( ) YOU "dept_list"

    DE oe_order_lines_all d d . line_id = 143424538 ;



    The output is:


    < majorLine Line Id='143424538'>

    < itemName > 15454-TCC3-K9 = </ itemName >

    < quantity > 10 < / quantity >

    < Service SERVICE='143424538'>

    < ServiceName ItemName'15454-TCC3-K9 ='=>

    < itemName > 15454-TCC3-K9 = </ itemName >

    < quantity > 10 < / quantity >

    </ ServiceName >

    </ Service >

    < minorLine MINORLINE='143424538'>

    < itemName ItemName'15454-TCC3-K9 ='=>

    < itemName > 15454-TCC3-K9 = </ itemName >

    < quantity > 10 < / quantity >

    </ itemName >

    </ minorLine >

    < service SERVICE='143424538'>

    < serviceName itemName'15454-TCC3-K9 ='=>

    < itemName > 15454-TCC3-K9 = </ itemName >

    < quantity > 10 < / quantity >

    </ serviceName >

    </ service >

    </ majorLine >

    But the production expected as below

    < majorLine Line Id="143">

    < itemName > 15454-K = </ itemName >

    < quantity > 10 < / quantity >

    < Service >

    < lineId >143424538 < / lineId >

    < itemName > 15454-9 = </ itemName >

    < quantity > 10 < / quantity >

    </ Service >

    < minorLine MINORLINE='143424538'>

    < itemName > 1549 = </ itemName >

    < quantity > 10 < / quantity >

    </ minorLine >

    < service >

    < lineId >143424538 < / lineId >  

    < itemName > 159= </ itemName >

    < quantity > 10 < / quantity >

    </ service >

    </ majorLine >



    So the exact structure of XML output will be like that. In the example above, I didn't add the service of minors and several minor lines.

    I need to change the code above in the format below.



    < majorLine = "123456" LineID >-> there will be only one line of Major

    < itemNamme > MajorLineItem < / itemName >

    < quantity > 2 < / quantity >

    < service > -> there may be more than one service or no service of this major axis

    < > < lineId > 123456 lineId

    < itemNamme > serviceOfmajor < / itemName >

    < quantity > 2 < / quantity >

    < / service >

    < minorLine LineID '456789' = > -> there are several minor this major line lines

    < itemNamme > first_MinorlineItem < / itemName >

    < quantity > 7 < / quantity >

    < service >-> there may be more than one or NONE of the lines of service for one minor line

    < > < lineId > 11212 lineId

    < itemNamme > First_serivceOfMinor < / itemName >

    < quantity > 2 < / quantity >      

    < / service >

    < service >-> it may be more than one service lines for a line of minor

    < > 1347657 < lineId > lineId

    < itemNamme > second_serivceOfMinor < / itemName >

    < quantity > 2 < / quantity >      

    < / service >

    < minorLine LineID = "477838" > -> there are several minor this major line lines

    < itemNamme > second_MinorlineItem < / itemName >

    < quantity > 3 < / quantity >

    < / majorLine >



    Please help me to re - write the code. I used the approach of DOM node, its very long, I'm trying to replace it. Help, please. Let me know if you have any questions.


    Thank you and best regards,

    Arun Thomas T





    Not a Constructive Question.

  • [10 g/8i] Need help with setting up a query

    I have a query that takes about 5 minutes to run, and if there is a way to make it faster, I would like to know. It is not a huge problem, but I get to sleep while waiting for it to end. =)

    Here are the results of the explain plan command and the extra stuff generated by autotrace...
    SQL> show parameter optimizer
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    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
    SQL> 
    SQL> show parameter db_file_multi
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    db_file_multiblock_read_count        integer     128
    SQL> 
    SQL> show parameter db_block_size
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    db_block_size                        integer     8192
    SQL> 
    SQL> show parameter cursor_sharing
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    cursor_sharing                       string      EXACT
    SQL> 
    SQL> column sname format a20
    SQL> column pname format a20
    SQL> column pval2 format a20
    SQL> 
    SQL> select
      2           sname
      3         , pname
      4         , pval1
      5         , pval2
      6  from
      7         sys.aux_stats$;
    
    SNAME                PNAME                      PVAL1 PVAL2
    -------------------- -------------------- ----------- --------------------
    SYSSTATS_INFO        STATUS                           COMPLETED
    SYSSTATS_INFO        DSTART                           02-07-2006 22:54
    SYSSTATS_INFO        DSTOP                            02-07-2006 22:54
    SYSSTATS_INFO        FLAGS                      1.000
    SYSSTATS_MAIN        CPUSPEEDNW               500.790
    SYSSTATS_MAIN        IOSEEKTIM                 10.000
    SYSSTATS_MAIN        IOTFRSPEED             4,096.000
    SYSSTATS_MAIN        SREADTIM
    SYSSTATS_MAIN        MREADTIM
    SYSSTATS_MAIN        CPUSPEED
    SYSSTATS_MAIN        MBRC
    SYSSTATS_MAIN        MAXTHR
    SYSSTATS_MAIN        SLAVETHR
    
    13 rows selected.
    
    Elapsed: 00:00:00.03
    SQL> explain plan into plan_table for
      2  SELECT     CONNECT_BY_ROOT b.parent_part                         AS part_nbr
      3       ,     b.parent_part
      4       ,     b.child_part
      5       ,     eval_number ('1' || SYS_CONNECT_BY_PATH (b.qty_per, '*'))     AS qty
      6       FROM     (
      7            SELECT     doc_nbr          AS parent_part
      8            ,     comp_part     AS child_part
      9            ,     line_nbr
     10            ,     qty_per
     11            FROM     bill@DB8I
     12            WHERE     lst_code     IN ('G','M')
     13            AND     begn_eff     <= SYSDATE
     14            AND     end_eff          > SYSDATE
     15            AND      component_type     = 'R'
     16            AND     doc_type     = 'BILL'
     17            AND     status          = 'RL'
     18            ) b
     19       ,     part@DB8I p
     20       ,     dual
     21       WHERE     b.child_part     = p.part_nbr
     22       START WITH     b.parent_part          = 'MYPARTNBR'
     23       CONNECT BY     b.parent_part          = PRIOR b.child_part
     24       AND          PRIOR p.part_type     = 'M'
     25  ;
    
    Explained.
    
    Elapsed: 00:00:00.23
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Plan hash value: 2565617462
    
    --------------------------------------------------------------------------------------------------
    | Id  | Operation                 | Name | Rows  | Bytes | Cost (%CPU)| Time     | Inst   |IN-OUT|
    --------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT          |      |     1 |   299 |   519  (14)| 00:00:07 |        |      |
    |*  1 |  CONNECT BY WITH FILTERING|      |       |       |            |          |        |      |
    |*  2 |   FILTER                  |      |       |       |            |          |        |      |
    |   3 |    COUNT                  |      |       |       |            |          |        |      |
    |   4 |     NESTED LOOPS          |      |     1 |   299 |   519  (14)| 00:00:07 |        |      |
    |   5 |      NESTED LOOPS         |      |     1 |   217 |   517  (14)| 00:00:07 |        |      |
    |   6 |       FAST DUAL           |      |     1 |       |     2   (0)| 00:00:01 |        |      |
    |   7 |       REMOTE              | BILL |     1 |   217 |   515  (14)| 00:00:07 |  DB8I  | R->S |
    |   8 |      REMOTE               | PART |     1 |    82 |     2   (0)| 00:00:01 |  DB8I  | R->S |
    |*  9 |   HASH JOIN               |      |       |       |            |          |        |      |
    |  10 |    CONNECT BY PUMP        |      |       |       |            |          |        |      |
    |  11 |    COUNT                  |      |       |       |            |          |        |      |
    |  12 |     NESTED LOOPS          |      |     1 |   299 |   519  (14)| 00:00:07 |        |      |
    |  13 |      NESTED LOOPS         |      |     1 |   217 |   517  (14)| 00:00:07 |        |      |
    |  14 |       FAST DUAL           |      |     1 |       |     2   (0)| 00:00:01 |        |      |
    |  15 |       REMOTE              | BILL |     1 |   217 |   515  (14)| 00:00:07 |  DB8I  | R->S |
    |  16 |      REMOTE               | PART |     1 |    82 |     2   (0)| 00:00:01 |  DB8I  | R->S |
    |  17 |   COUNT                   |      |       |       |            |          |        |      |
    |  18 |    NESTED LOOPS           |      |     1 |   299 |   519  (14)| 00:00:07 |        |      |
    |  19 |     NESTED LOOPS          |      |     1 |   217 |   517  (14)| 00:00:07 |        |      |
    |  20 |      FAST DUAL            |      |     1 |       |     2   (0)| 00:00:01 |        |      |
    |  21 |      REMOTE               | BILL |     1 |   217 |   515  (14)| 00:00:07 |  DB8I  | R->S |
    |  22 |     REMOTE                | PART |     1 |    82 |     2   (0)| 00:00:01 |  DB8I  | R->S |
    --------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - filter("DOC_NBR"='MYPARTNBR')
       2 - filter("DOC_NBR"='MYPARTNBR')
       9 - access("DOC_NBR"=NULL AND NULL='M')
    
    Remote SQL Information (identified by operation id):
    ----------------------------------------------------
    
       7 - SELECT "DOC_NBR","BEGN_EFF","END_EFF","LST_CODE","COMP_PART_NBR","QTY_PE
           R","COMPONENT_TYPE","DOC_TYPE","STATUS" FROM "BILL" "BILL" WHERE "COMPONENT_TYPE"='R' AND
           "DOC_TYPE"='BILL' AND "STATUS"='RL' AND ("LST_CODE"='G' OR "LST_CODE"='M') AND
           "END_EFF">:1 AND "BEGN_EFF"<=:2 (accessing 'DB8I ' )
    
       8 - SELECT "PART_NBR","PART_TYPE" FROM "PART" "P" WHERE :1="PART_NBR" (accessing
           'DB8I ' )
    
      15 - SELECT "DOC_NBR","BEGN_EFF","END_EFF","LST_CODE","COMP_PART_NBR","QTY_PE
            R","COMPONENT_TYPE","DOC_TYPE","STATUS" FROM "BILL" "BILL" WHERE "COMPONENT_TYPE"='R' AND
            "DOC_TYPE"='BILL' AND "STATUS"='RL' AND ("LST_CODE"='G' OR "LST_CODE"='M') AND
            "END_EFF">:1 AND "BEGN_EFF"<=:2 (accessing 'DB8I ' )
    
      16 - SELECT "PART_NBR","PART_TYPE" FROM "PART" "P" WHERE :1="PART_NBR" (accessing
            'DB8I ' )
    
      21 - SELECT "DOC_NBR","BEGN_EFF","END_EFF","LST_CODE","COMP_PART_NBR","QTY_PE
            R","COMPONENT_TYPE","DOC_TYPE","STATUS" FROM "BILL" "BILL" WHERE "COMPONENT_TYPE"='R' AND
            "DOC_TYPE"='BILL' AND "STATUS"='RL' AND ("LST_CODE"='G' OR "LST_CODE"='M') AND
            "END_EFF">:1 AND "BEGN_EFF"<=:2 (accessing 'DB8I ' )
    
      22 - SELECT "PART_NBR","PART_TYPE" FROM "PART" "P" WHERE :1="PART_NBR" (accessing
            'DB8I ' )
    
    
    ...
    ...
    ...
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - filter("DOC_NBR"='MYPARTNBR')
       2 - filter("DOC_NBR"='MYPARTNBR')
       9 - access("DOC_NBR"=NULL AND NULL='M')
    
    Remote SQL Information (identified by operation id):
    ----------------------------------------------------
    
       7 - SELECT "DOC_NBR","BEGN_EFF","END_EFF","LST_CODE","COMP_PART_NBR","QTY_PE
           R","COMPONENT_TYPE","DOC_TYPE","STATUS" FROM "BILL" "BILL" WHERE "COMPONENT_TYPE"='R' AND
           "DOC_TYPE"='BILL' AND "STATUS"='RL' AND ("LST_CODE"='G' OR "LST_CODE"='M') AND
           "END_EFF">:1 AND "BEGN_EFF"<=:2 (accessing 'DB8I ' )
    
       8 - SELECT "PART_NBR","PART_TYPE" FROM "PART" "P" WHERE :1="PART_NBR" (accessing
           'DB8I ' )
    
      15 - SELECT "DOC_NBR","BEGN_EFF","END_EFF","LST_CODE","COMP_PART_NBR","QTY_PE
            R","COMPONENT_TYPE","DOC_TYPE","STATUS" FROM "BILL" "BILL" WHERE "COMPONENT_TYPE"='R' AND
            "DOC_TYPE"='BILL' AND "STATUS"='RL' AND ("LST_CODE"='G' OR "LST_CODE"='M') AND
            "END_EFF">:1 AND "BEGN_EFF"<=:2 (accessing 'DB8I ' )
    
      16 - SELECT "PART_NBR","PART_TYPE" FROM "PART" "P" WHERE :1="PART_NBR" (accessing
            'DB8I ' )
    
      21 - SELECT "DOC_NBR","BEGN_EFF","END_EFF","LST_CODE","COMP_PART_NBR","QTY_PE
            R","COMPONENT_TYPE","DOC_TYPE","STATUS" FROM "BILL" "BILL" WHERE "COMPONENT_TYPE"='R' AND
            "DOC_TYPE"='BILL' AND "STATUS"='RL' AND ("LST_CODE"='G' OR "LST_CODE"='M') AND
            "END_EFF">:1 AND "BEGN_EFF"<=:2 (accessing 'DB8I ' )
    
      22 - SELECT "PART_NBR","PART_TYPE" FROM "PART" "P" WHERE :1="PART_NBR" (accessing
            'DB8I ' )
    
    
    
    Statistics
    ----------------------------------------------------------
            381  recursive calls
              1  db block gets
              0  consistent gets
              0  physical reads
            304  redo size
          15558  bytes sent via SQL*Net to client
            417  bytes received via SQL*Net from client
              5  SQL*Net roundtrips to/from client
              6  sorts (memory)
              0  sorts (disk)
            379  rows processed
    
    SQL> disconnect
    Disconnected from Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    I also have the tkprof output, but let's start with that. I have absolutely no idea where to even start looking for something to improve.

    Performance would be much better if the whole query would be executed on the remote side, but the query uses the local function eval_number as well as parts of the query are executed on the remote side and results are brought alongside local and then only filtering is performed. Try the following:

    SELECT  part_nbr,
            parent_part,
            child_part,
            eval_number ('1' || path) qty
      FROM  (
             SELECT  CONNECT_BY_ROOT b.parent_part part_nbr,
                     b.parent_part,
                     b.child_part,
                     SYS_CONNECT_BY_PATH(b.qty_per, '*') path
               FROM  (
                      SELECT  doc_nbr parent_part,
                              comp_part child_part,
                              line_nbr
                              qty_per
                        FROM  bill@DB8I
                        WHERE lst_code IN ('G','M')
                          AND begn_eff <= SYSDATE
                          AND end_eff  > SYSDATE
                          AND component_type = 'R'
                          AND doc_type = 'BILL'
                          AND status  = 'RL'
                     ) b,
                     part@DB8I p
               WHERE b.child_part = p.part_nbr
               START WITH b.parent_part  = 'MYPARTNBR'
               CONNECT BY b.parent_part  = PRIOR b.child_part
                   AND PRIOR p.part_type = 'M'
            )
    /
    

    SY.

  • Need help with order by clause row_number() Fn

    with t as
    (
     select 123 id, 'brwr' lstatus from dual
     union all
     select 123 id, 'ca' lstatus from dual
     union all
     select 123 id, 'fac' lstatus from dual
     union all
     select 345 id, 'ca' lstatus from dual
     union all
     select 345 id, 'brwr' lstatus from dual
     union all
     select 567 id, 'brwr' lstatus from dual
     union all
     select 789 id, 'brwr' lstatus from dual
     union all
     select 1011 id, 'fac' lstatus from dual
    union all
     select 1011 id, 'xyz' lstatus from dual
    )select id,lstatus,row_number() over(partition by id order by lstatus)rw
     from t;
    Desired output
    id           lstatus       rn
    
    123         brwr         3
    123         ca          1
    123         fac         2
    345         ca          1
    345         brwr         2
    567         brwr         1
    789         brwr         1
    1011         fac        1
    1011  xyz         2
    That is, my first priority is to 'ca', then 'College '.

    I am aware that this can be done through the use of CASE within the order by clause
    but could not find the logic of the apt.

    Please help me.

    A solution just for data given to samples...

    with t as
    (
     select 123 id, 'brwr' lstatus from dual
     union all
     select 123 id, 'ca' lstatus from dual
     union all
     select 123 id, 'fac' lstatus from dual
     union all
     select 345 id, 'ca' lstatus from dual
     union all
     select 345 id, 'brwr' lstatus from dual
     union all
     select 567 id, 'brwr' lstatus from dual
     union all
     select 789 id, 'brwr' lstatus from dual
     union all
     select 1011 id, 'fac' lstatus from dual
    union all
     select 1011 id, 'xyz' lstatus from dual
    )select id,lstatus,row_number() over(partition by id order by (case  when lstatus <> 'brwr' THEN UPPER(lstatus) else lstatus end)) rw
     from t;
    

    Basically, it shows how to use the CASE statement. You can change based on your actual data.

    Concerning
    Arun

  • Need help with a self-join query

    Hello
    I have A table with the following data

    OID parent_oid
    4 of 10
    4 2
    2 2
    12 6
    6 6

    parent_oid is the parent of the oid. I would like a query that displays the final parent of the oid. The result must indicate the following

    Final parent OID
    2 of 10
    4 2
    2 2
    12 6
    6 6

    I use Oracle 10 g. I am familiar with free joins, but that alone will not do the job. Thank you!

    Hello

    arizona9952 wrote:
    ... I am familiar with free joins, but that alone will not do the job.

    You are absolutely right!

    A self-join 2-way would work for lines have no parent, or lines which are directly related to their final ancestor (such as the oid = 4), but not for what anyone further.
    A 3-way self-join would work to a level more away from the last row, but no more. That would be enough with the small set of sample data that you posted, but it won't work if you have added a new rank parent_id = 10.
    An N - way self-join would work for up to N + 1 levels, but no more.

    You need something that can go to any number of levels, such as CONNECT BY:

    SELECT     CONNECT_BY_ROOT oid     AS oid
    ,     parent_oid          AS final_parent
    FROM     a
    WHERE     CONNECT_BY_ISLEAF     = 1
    CONNECT BY     oid     = PRIOR parent_oid
         AND     oid     != parent_oid
    ;
    

    Published by: Frank Kulash, February 22, 2010 19:09

    On sober reflection, I think that a request from top down, as one below, would be more effective than a motion up and down, like the one above:

    SELECT     oid
    ,     CONNECT_BY_ROOT     parent_oid     AS final_parent
    FROM     a
    START WITH     parent_oid     = oid
    CONNECT BY     parent_oid     = PRIOR oid
         AND     oid          != PRIOR oid
    ;
    
  • Need help with orders to clear a N2024 stacked switch port configuration

    The current config is:

    interface item in gi1/0/20

    Speed 1000

    Description "WifiLocation2".

    VLAN allowed switchport General add 154

    switchport general allowed vlan add 153 tag

    switchport vlan allowed General remove 1

    switchport access vlan 15

    LLDP transmit tlv ESCR-sys sys - cap

    LLDP transmit-mgmt

    notification of LLDP

    LLDP-med confignotification

    disable voice vlan auth

    I need to look like:

    interface item in gi1/0/20

    Description "WifiLocation2".

    switchport access vlan 15

    I tried a lot of things, but cannot get rid of the lines switchport

    any help would be appreciated

    Clayton

    Another way to remove the general lines switchport is to use the option "Delete" on all VLANs currently associated.  Just like what has been done for the vlan 1 in your example. Something like this:

    switchport vlan allowed General remove 153, 154

    Make sure you have the mode set correctly.  By default, the access mode is set.  If the default value of access is being used, the lines "switchport general" are ignored anyway.

    Hope this has been helpful.

    B

  • Need help with a query result

    Oracle Version: 11.2.0.2.0

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

    With Tbl_Nm as

    (

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

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

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

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

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

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

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

    )

    Select * from tbl_nm

    I need the output below.

    PQR2 UK MC 2600 1 OCTOBER 2012 04:45

    ABC1 US NY 3500 October 1, 2012 06:45

    LMN3 UK BT 2500 November 1, 2012 07:45

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

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

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

    With Tbl_Nm as

    (

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

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

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

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

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

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

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

    )

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

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

    So maybe you'd then

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

    to get the Ds at the end of the list.

    or

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

    HTH

  • Need help with a SQL query

    Hello

    I have a data in table (raj_table) with columns (char11) raj_id, raj_number (varchar2 (15)), raj_format (NUMBER), Primary_ID (identity with the values of the primary key column)

    Primary_ID raj_id Raj_number Raj_format

    1                            raj                 rajvend                      1

    2                            raj                 rajvend                      1

    3                            raj                 rajvendor1                 2

    4                            raj                 rajvendor1                 2

    5                            raj                 rajvendor1                 2

    6                            raj                 rajvendor2                 3

    I used under SQL to get query output as below, but has not achieved the required result:

    Select client_id vendor_number, vendor_format, primary_id, row_number() on sl_no (client_id partition, primary_id, vendor_format order of client_id primary_id, vendor_format, vendor_number, vendor_number)

    from raj_table by sl_no asc

    SL_NO raj_id raj_number raj_format primary_id

    1                   1                   raj              rajvendor                 1

    1                   2                  raj              rajvendor                 1

    2                   3                   raj              rajvendor1                2

    2                   4                   raj              rajvendor1                2

    2                   5                  raj               rajvendor1                2

    3                   6                    raj              rajvendor2                3

    I need help with a SQL query to get the result as above without using the group by clause. I want to bring together the combination of separate line of the three columns (raj_id, raj_number, raj_format) and add a unique serial number for each online game (SL_NO column below). So, above there are 3 unique set of (raj_id, raj_number, raj_format) I can get in a group by clause, but I can not add prmiary_id, SL_NO values if I group by clause. I used the analytical functions like row_number() but no luck. Need solution for this.

    with t as)

    Select 'raj' raj_id, 'rajvend' raj_number, 1 raj_format, 1 primary_id Union double all the

    Select option 2, 'raj', 'rajvend', 1 double Union all

    Select 3, 'raj', 'rajvendor1', 2 double Union all

    Select 4, 'raj', 'rajvendor1', 2 double Union all

    Select 5, 'raj', 'rajvendor1', 2 double Union all

    Select 6, 'raj', 'rajvendor2', 3 double

    )

    Select dense_rank() over (order of raj_id, raj_number, raj_format) sl_no,

    t.*

    t

    order by primary_id

    /

    PRIMARY_ID RAJ RAJ_NUMBER RAJ_FORMAT SL_NO
    ---------- ---------- --- ---------- ----------
    1 1 raj rajvend 1
    1 2 raj rajvend 1
    2 3 raj rajvendor1 2
    2 4 raj rajvendor1 2
    2 5 raj rajvendor1 2
    3 6 raj rajvendor2 3

    6 selected lines.

    SQL >

    SY.

  • Need help with query Cumulative difference

    Hi all

    I need help with a query and my requirement is as below

    {code}

    ROWNOORDERSVALUE

    110900
    211700
    312500
    413400

    {/ code}

    I have need to query which will display the cumulative difference for example I value tell 10000 numbers opening

    now I need for each of the lines of cumulative difference

    {code}

    ROWNO ORDERS DIFF

    1 10 10000 - 900 = 9100

    2 11 9100 - 700 = 8400

    3 12 8400 - 500 = 7900

    4 13 7900 - 400 = 7500

    {/ code}

    WITH commands LIKE (10 SELECT order_id, 900 double UNION ALL val
    11. SELECT, 700 FROM dual UNION ALL
    SELECT 12, 500 FROM dual UNION ALL
    Select 13, 400 double)

    SELECT row_number() over (ORDER BY order_id ASC) AS rowno
    order_id
    sum (val) 10000 - OVER (ORDER BY order_id ASC) AS diff
    orders

    /

    HTH

  • Need help with PL/SQL query complex

    I need help with a query that need access to data from 3 tables. That's what I did

    I created 3 tables

    CREATE TABLE post_table
    (
    post_id varchar (20),
    datepost DATE,
    KEY (post_id) elementary SCHOOL
    ) ;

    CREATE TABLE topic
    (
    TOPIC_ID varchar (20),
    name varchar (20),
    PRIMARY KEY (topic_id)
    );

    CREATE TABLE blogpost_table
    (
    TOPIC_ID varchar (20),
    post_id varchar (20),
    PRIMARY KEY (topic_id, post_id);
    FOREIGN KEY (topic_id) REFERENCES topic (topic_id) ON DELETE CASCADE,
    FOREIGN KEY (post_id) REFERENCES post_table (post_id) ON DELETE CASCADE
    );


    Now, I inserted a few values in these tables as

    INSERT INTO post_table VALUES ('p1', to_date ('2009-09-14 18:00 "," MM/DD/YYYY mi:ss'));))
    INSERT INTO post_table VALUES ('p2', to_date ('2009-07-18 18:00 "," MM/DD/YYYY mi:ss'));))
    INSERT INTO post_table VALUES ('p3', to_date ('2009-07-11 18:00 "," MM/DD/YYYY mi:ss'));))
    INSERT INTO post_table VALUES ('p4', to_date ('2009-03-11 18:00 "," MM/DD/YYYY mi:ss'));))
    INSERT INTO post_table VALUES ('p5', to_date ('2009-07-13 18:00 "," MM/DD/YYYY mi:ss'));))
    INSERT INTO post_table VALUES ('p6', to_date ('2009-06-12 18:00 "," MM/DD/YYYY mi:ss'));))
    INSERT INTO post_table VALUES ('p7', to_date ('2009-07-11 18:00 "," MM/DD/YYYY mi:ss'));))

    INSERT INTO VALUES subject ("t1", "baseball");
    INSERT INTO category VALUES ('t2', 'football');

    INSERT INTO blogpost_table VALUES ("t1", "p1");
    INSERT INTO blogpost_table VALUES ('t1', 'p3');
    INSERT INTO blogpost_table VALUES ("t1", "p4");
    INSERT INTO blogpost_table VALUES ('t1', 'p5');
    INSERT INTO blogpost_table VALUES ('t2', 'p2');
    INSERT INTO blogpost_table VALUES ('t2', 'p6');
    INSERT INTO blogpost_table VALUES ("t2", "p7");


    I'm launching SQL queries on the table in this topic.

    I want to write a SQL query that returns me the name of a topic (s) and the number of blog_post (s) associated with the topic in descending order of the number of blog posts created in July.

    Can someone please help me to write this query?

    Thank you

    Published by: user11994430 on October 9, 2009 07:24

    Thanks for the test of the configuration!

    SQL>SELECT   t.NAME, COUNT(*)
      2      FROM topic t, blogpost_table b, post_table p
      3     WHERE b.topic_id = t.topic_id
      4       AND p.post_id = b.post_id
      5       AND p.datepost >= DATE '2009-07-01'
      6       AND p.datepost < DATE '2009-08-01'
      7  GROUP BY t.NAME
      8  ORDER BY COUNT(*) desc;
    
    NAME                   COUNT(*)
    -------------------- ----------
    baseball                      2
    soccer                        2
    

    HTH, Urs

  • Need help with query between 2 dates

    Hello

    I did not SEE in a long time and need help with a simple query.

    I have a table of DB access with 3 fields, name, date and number

    What I want is to create a query to retrieve all the names between 2 dates

    When I ask the date field, the results are showing in this formats 2013-07-12 00:00:00

    Here's my query

    < cfquery datasource = 'mydb' name = 'test' >

    SELECT name from myTable

    where edate between ' 2011-01-01 00:00:00 ' AND ' 2013-01-01 00:00:00 '

    < / cfquery >

    < cfoutput query = 'test' >

    #name #.

    < / cfoutput >

    What I get is this error

    ODBC = 22005 (assignment error) error code

    [Microsoft] [ODBC Microsoft Access driver] Type mismatch of data in the expression of the criteria.

    Don't know what I'm doing wrong here.

    Please let me know.

    Thank you

    SELECT ename

    FROM MyTable

    WHERE edate BETWEEN

    AND

    #ename #.

  • Need help with query SQL Inline views + Group

    Hello gurus,

    I would really appreciate your time and effort on this application. I have the following data set.

    Reference_No---Check_Number---Check_Date---description---Invoice_Number---Invoice_Type---Paid_Amount---Vendor_Number
    1234567 11223 - 05/07/2008 -paid for cleaning- 44345563-I-* 20.00 *---19
    1234567 11223 - 05/07/2008 - 44345563 -a--10,00---19 ofbad quality adjustment
    7654321 11223 - 05/07/2008 - setting the last billing cycle - 23543556 - A - 50.00 - 19
    4653456 11223 - 05/07/2008 - paid for cleaning - 35654765 - I - 30, 00-19

    Please ignore '-' added for clarity

    I'm writing a paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, aggregate query Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Type, Invoice_Number, Vendor_Number. When there are no more records I want to display the respective Description.

    The query should return the following data set

    Reference_No---Check_Number---Check_Date---description---Invoice_Number---Invoice_Type---Paid_Amount---Vendor_Number
    1234567 11223 - 05/07/2008 -paid for cleaning- 44345563-I-* 10.00 *---19
    7654321 11223 - 05/07/2008 - setting the last billing cycle - 23543556 - A - 50.00 - 19
    4653456 11223 - 05/07/2008 - paid for cleaning - 35654765 - I - 30, 00-19
    Here's my query. I'm a little lost.

    Select b., A.sequence_id, A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
    de)
    Select sequence_id, check_number, check_date, invoice_number, sum (paid_amount) sum, vendor_number
    of the INVOICE
    Sequence_id group check_date, check_number, invoice_number, vendor_number
    ) A, B OF INVOICE
    where A.sequence_id = B.sequence_id


    Thank you
    Nick

    It seems that this is a duplicate thread - correct me if I am wrong in this case->

    Need help with query SQL Inline views + Group

    Kind regards.

    LOULOU.

  • Need help with network home using Airport extreme

    I need help with my home network.  I'm not very aware when it comes to all things network.  Here's how my network is currently set up.

    Cable modem to Airport Extreme for Gigabit Switch.  Cables come out of the switch to all areas of the House.  I have 2 other extreme airport connected in other rooms of the House directly on the wall that dates back to the switch.  I hope I am explaining that properly.

    My problem is that this seems to have caused some of my connections cable does not work.  When everything is configured, it has worked well.  All connections in the House worked.  Then we have disconnected one of the extreme airport and moved to another location in the House to have the best wifi coverage.  Since that time, a lot of the ethernet wall plugs are not working.  For example, when I plug in my Macbook Pro in making ethernet in my kitchen, it says connected but it has an assigned ip address and cannot connect to the internet.

    Any help you can provide would be great.

    I would like to get the return tech to help you to...

    But it is likely that something (or someone) has tampered with the settings.

    The layout is fine... but you can cause problems with the network by creating a loop.

    This can happen because the AE you moved is connected wrongly... somewhere in the network it is connected to the switch again.

    Or AE is set to expand wireless... It's FAKE... It will loop the network on the back main EI wireless.

    Unplug the two AE you have that function as extensions...

    Turning off everything else... then it works again...

    Do it in this order.

    Modem... Wait 2 min

    AE... Wait 2 min

    Switch.

    Now check that the network is working properly... power of customers in various locations and make sure everything is good.

    If so, then manually reset the two AE of factory and redo their installation.

  • Need help with windows defender. all my files folders pictures everythiing disappeared and I find myself with this black screen and it is not all good: o)

    Need help with windows defender. all my files folders pictures everythiing disappeared and I find myself with this black screen and it is not all good: o)

    I don't know why vista windows no longer charge, or when the files and folders disappeared

    How Windows Defender is on this problem?

    Follow these steps to try to solve your problems of boot.

     

     

    Restore point:

    Try typing F8 at startup and in the list of Boot selections, select Mode safe using ARROW top to go there > and then press ENTER.

    Try a restore of the system once, to choose a Restore Point prior to your problem...

    Click Start > programs > Accessories > system tools > system restore > choose another time > next > etc.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

     

    If restore work not and you do not have a Vista DVD from Microsoft, do a repair disc to do a Startup Repair:

    Download the ISO on the link provided and make a record of repair time it starts.

    Go to your Bios/Setup, or the Boot Menu at startup and change the Boot order to make the DVD/CD drive 1st in the boot order, then reboot with the disk in the drive.

    At the startup/power on you should see at the bottom of the screen either F2 or DELETE, go to Setup/Bios or F12 for the Boot Menu.

    When you have changed that, insert the Bootable disk you did in the drive and reboot.

    http://www.bleepingcomputer.com/tutorials/tutorial148.html

    Link above shows what the process looks like and a manual, it load the repair options.

    NeoSmart containing the content of the Windows Vista DVD 'Recovery Centre', as we refer to him. It cannot be used to install or reinstall Windows Vista, and is just a Windows PE interface to recovering your PC. Technically, we could re-create this installation with downloadable media media freely from Microsoft (namely the Microsoft WAIK, several gigabyte download); but it is pretty darn decent of Microsoft to present Windows users who might not be able to create such a thing on their own.

    Read all the info on the website on how to create and use:

    http://NeoSmart.net/blog/2008/Windows-Vista-recovery-disc-download/

    ISO Burner:http://www.snapfiles.com/get/active-isoburner.html

    It's a very good Vista startup repair disk.

    You can do a system restart tool, system, etc it restore.

    It is NOT a disc of resettlement.

    And the 32-bit is what normally comes on a computer, unless 64-bit.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Data recovery:

    1. slave of your hard drive in another computer and read/save your data out there.

    2. put your Hard drive in a USB hard drive case, plug it into another computer and read/save from there.

    3 Alternatively, use Knoppix Live CD to recover data:

    http://www.Knopper.NET/Knoppix/index-en.html

    Download/save the file Knoppix Live CD ISO above.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    http://isorecorder.alexfeinman.com/isorecorder.htm

    Download the Vista software from the link above.

    After installing above ISO burning software, right click on the Knoppix ISO file > copy the Image to a CD.

    Knoppix is not installed on your PC; use only the resources of your PC, RAM, graphics etc.

    Change the boot order in YOUR computer/laptop to the CD/DVD Drive 1st in the boot order.

    Plug a Flash Drive/Memory Stick, BOOT with the Live CD, and you should be able to read the hard drive.

    When the desktop loads, you will see at least two drive hard icons on the desktop (one for your hard drive) and one for the USB key.

    Click on the icons of hard drive to open and to understand which drive is which.

    Click the icon for the USB drive and click on "Actions > Change the read/write mode" so you can write to disk (it is read-only by default for security reasons).

    Now to find the files you want to back up, just drag and drop them on the USB. When you're done, shut down the system and remove the USB key.

    See you soon.

    Mick Murphy - Microsoft partner

Maybe you are looking for

  • Tecra M5 - PCI device under other devices

    What is this possible? any idea please?Thank youJon

  • WGAErrLog

    D446F964-596-80004005_D446F964-495-80004005_D446F964-596-80004005_D446F964-495-80004005_D446F964-596

  • E270 en modo DPW, no lo reconoce mi PC,

    Mi Sansa e270, 6.0 GB, en modo DPW, none are representatives por mi PC, el cual utilizo Windows XP profecional, y el programa windows media player 11, tambien el used he 10. Por lo tanto no he could trasferir a list of players of las mi Sansa, than I

  • DVD RW drive (e :)) don't read do not all disks)

    I have a Dell Studio Windows Vista. The DVD RW drive (e :)) does not.) Regardless of the type of disc that I put in, my DVD player does not recognize. When I go to 'My Computer' to open the disc manually, a message appears telling me to insert a disc

  • ButtonField image

    Hy guys That's the problem BitmapField bfSeat = new BitmapField (Bitmap.getBitmapResource ("seat_service.png"), BitmapField.FOCUSABLE);bfSeat.setChangeListener (new FieldChangeListener() {}' Public Sub fieldChanged (field field, int context) {} When