use the sequence grouping conditional Dynamics

Hi experts,

I have a simple task (?) - I want number (assign) groups (increase the number of Group) based on a condition.

Here is an example: create groups numbered according to the number of Department (as per the same collection)
create table emp as
select * from scott.emp;

CREATE SEQUENCE group_no;
SELECT group_no.NEXTVAL FROM DUAL;
SELECT group_no.CURRVAL FROM DUAL;

/* automatic grouping - NOT WORKING!!!! */ 
  select ename, deptno, deptno_next, deptno_prev, 
   case when (deptno_next > deptno) then group_no.nextval else 1 end grp 
    from
      (select ename, deptno,
              lead(deptno) over (order by deptno) deptno_next,
              lag(deptno) over (order by deptno) deptno_prev
      from emp
      );
PROBLEM:
It seems that the sequence is increased, even when the condition for a new number is not satisfied!
NAME      DEPTNO                 DEPTNO_NEXT            DEPTNO_PREV            GRP                    
---------- ---------------------- ---------------------- ---------------------- ---------------------- 
CLARK      10                     10                                            1                      
KING       10                     10                     10                     1                      
MILLER     10                     20                     10                     130                    
JONES      20                     20                     10                     1                      
FORD       20                     20                     20                     1                      
ADAMS      20                     20                     20                     1                      
SMITH      20                     20                     20                     1                      
SCOTT      20                     30                     20                     135                   
WARD       30                     30                     20                     1                      
TURNER     30                     30                     30                     1                      
ALLEN      30                     30                     30                     1                      
JAMES      30                     30                     30                     1                      
BLAKE      30                     30                     30                     1                      
MARTIN     30                                            30                     1
Instead of
else 1
I use group_no.currval (same group number, when does not change do not Department). I know, I need to cover the previous number as well, but I did simple, because the problem here seems to be the sequence...

Forward your support :-)
Duik

Published by: user10939560 on 08.10.2012 07:42

Published by: user10939560 on 08.10.2012 07:44

Published by: user10939560 on 08.10.2012 07:45

Published by: user10939560 on 08.10.2012 07:48

Published by: user10939560 on 08.10.2012 07:49

"I want number (assign) groups (increase the number of Group) based on a condition."

But he did exactly want you want. The number of groups is increasing. It is not contiguous, which
You can not guarantee for sequences of anyway.

However, if I understand you correctly, it's maybe you need:

      select ename,deptno,
      dense_rank() over (order by deptno) grp
      from emp;

If this isn't the case, please explain in more detail what you are trying to do.

Published by: Paul Horth on October 8, 2012 08:06

Tags: Database

Similar Questions

  • How can I use the sequence of the string "\u00e5" in myfile.txt converted unic

    How can I use the sequence of the string "\u00e5" in myfile.txt converted to unicode in my application?

    I have a text file, MyFile.txt, with some sequences represented unicode:
    \u00e5
    \u00e4
    \u00f6
    etc.

    This is the file contains unicode, not the character it represents: a, a and o.
    I get the sequence of the file and save it to a vector. When I tried to use it on a JButton, I see the "\u00e5" string and not the character that I assumed.

     
            read file codes ...
            ...
         Vector<String> glyphVector = readGlyphIndex.getUnicodeFiles();     // to retrieve the vector with unicode sequence and save it to glyphVector
         String unicode = glyphVector.get(0);     //get the first unicode sequence
            System.out.println(unicode);    //displays \u00e5 and not å in the console.
         jButton.setText(unicode);   //jButton is a JButton and it shows the string \00e5 and not the character å
            ...
    The question is how to convert the sequence of string to be a unicode escape in the code?

    In order to make it clear:
    //from
    jButton.setText("\\u00e5");
    //to
    jButton.setText("\u00e5");
    Thanks in advance!

    Dragonfly
    String s = Character.toString((char) unicodeInInt);
    

    Strictly speaking, if unicodeInInt is a Unicode code point (for example, it can be greater than 0xFFFF) then the correct code would be this:

    String s = new String(Character.toChars(unicodeInInt));
    

    However, since the "\u" notation allows only 4 hexadecimal digits (and need to 0xFFFF code points > Unicode represented by their UTF-16 encoding), the code above is not enough for this particular case.

  • Use the dynamic filter Condition in the mapping

    Hello

    I tried to use a dynamic filter condition in my correspondence.

    I wrote this condition as:

    INOUTGRP1. Numer1 = ' | Number 1 | '
    and INOUTGRP1. Number2 = ' | Number2 '

    Number1 and number2 are setting for mapping entry, now I want to use the input parameter for the Filter Condition.

    Can someone tell me how I can handle this?

    Thanks in advance.

    Greetings

    You used wrong input parameters.
    Rather a link an input parameter to the operator to filter, then you can insert it from list of attributes as long as the same way as other attributes of filter operator group

    Kind regards
    Oleg

  • SSL VPN authentication using the ad group

    Hi all

    I tried to restrict users to authenticate to the SSL VPN using an ad server. I have install the AAA server with the IP address of the AD server and attributed to the connection profile as well; However, I see that any user who is a member of a group in AD is able to authenticate.

    I want to only users who belong to the group "VPN users" get authenticated while everyone and all those who have credentials of the AD and not even a part of the 'VPN users' group is making authenticated.

    Can someone advice how I can make the ASA authenticate users based on ad groups? I use the ASDM to configure my VPN RA.

    Thanks in advance!

    Kind regards

    Riou

    Hey riri,.

    Try to use DAP to restrict access to users who belong to a specific ad group:

    https://supportforums.Cisco.com/document/7691/ASA-8X-dynamic-access-poli...

    Use the AAA attribute "LDAP .member of" to allow access to the users belonging to a specific group and deny access to other users.

    concerning

    Eric

  • using the query - group

    Hi all
    I need to get the sum (sal) and the sum (comm) using the select query...
    I use a group of... but could not get the result...
    For example... If the table is
    ENO ename sal comm deptno job
    1234 2000 1 10 Chief john
    1235 1000 2 20 andrew seller
    1236 2000 3 20 steven Manager
    Clerk robert 1237 600 4 10
    Manager of laura 1238 2000 5 20
    1239 500 6 30 dan seller
    1240 500 7 10 james clerk

    I need display all the columns in the select query and the result should be as follows:
    ENO ename sal comm deptno sum (sal) sum (comm) employment
    1234 2000 1 10 6000 9 Chief john
    1235 1000 2 20 1500 8 andrew seller
    1236 2000 3 20 6000 9 steven Manager
    Clerk robert 1237 600 4 10 1100 11
    1238 2000 5 20 6000 9 laura Manager
    1239 500 6 30 1500 8 dan seller
    1240 500 7 10 1100 11 james clerk

    I appreciate your help... Thank you!

    Use anaytic SUM:

    SQL> select  empno,
      2          ename,
      3          job,
      4          sal,
      5          comm,
      6          deptno,
      7          sum(sal) over(partition by deptno) sum_sal,
      8          sum(comm) over(partition by deptno) sum_comm
      9    from  emp
     10  /
    
         EMPNO ENAME      JOB              SAL       COMM     DEPTNO    SUM_SAL   SUM_COMM
    ---------- ---------- --------- ---------- ---------- ---------- ---------- ----------
          7782 CLARK      MANAGER         2450                    10       8750
          7839 KING       PRESIDENT       5000                    10       8750
          7934 MILLER     CLERK           1300                    10       8750
          7566 JONES      MANAGER         2975                    20      10875
          7902 FORD       ANALYST         3000                    20      10875
          7876 ADAMS      CLERK           1100                    20      10875
          7369 SMITH      CLERK            800                    20      10875
          7788 SCOTT      ANALYST         3000                    20      10875
          7521 WARD       SALESMAN        1250        500         30       9400       2200
          7844 TURNER     SALESMAN        1500          0         30       9400       2200
          7499 ALLEN      SALESMAN        1600        300         30       9400       2200
    
         EMPNO ENAME      JOB              SAL       COMM     DEPTNO    SUM_SAL   SUM_COMM
    ---------- ---------- --------- ---------- ---------- ---------- ---------- ----------
          7900 JAMES      CLERK            950                    30       9400       2200
          7698 BLAKE      MANAGER         2850                    30       9400       2200
          7654 MARTIN     SALESMAN        1250       1400         30       9400       2200
    
    14 rows selected.
    
    SQL> 
    

    SY.

  • How to use the search otherwise condition as

    Oracle 9i

    Hi all

    I work in the management of control here, we have a table named as OE_ORDER_LINES_ALL and the name of the column called UPI, and its length is 16 tank.

    Now the customer has the UPI with 13 tank and now, I need to check if all the IPUS are in the table.
    I have almost 600 of the UPI and I can't able to use as an operator. Y at - it one option other than as an operator.

    For example

    Resemble UPI this 050 009714373007G, but the customer gave this G 009714373007.

    Is there a UPI then I would use like this

    "Select upi in oe_order_lines_all where the upi as ' 009714373007 G %.

    If there is more than 2 UPIs how to use the search condition

    Any help is highly appricatable

    Thanks and greetings
    Srikkanth.M

    If you know that you will benefit from a number of values of UPI 13 characters and you should look for if there are rows in the table that match the 13 first characters

    select upi
      from oe_order_lines_all
     where substr(upi,1,13) IN( '009714373007G', <> )
    

    Justin

  • Better to use the sequence of one or more?

    Hello

    I have several tables, each with its own primary key. I don't like what are the values of primary keys; they do not have to be sequential or anything. Should I set a separate sequence for each table, or just set a single sequence and reuse it for all tables? Is how important it? Thanks for your help.

    928546 wrote:
    Hello

    I have several tables, each with its own primary key. I don't like what are the values of primary keys; they do not have to be sequential or anything. Should I set a separate sequence for each table, or just set a single sequence and reuse it for all tables? Is how important it? Thanks for your help.

    His 'clean' to have a specific sequence for each table. If nothing else, it's how things are generally implemented and when others see your design are likely to expect. In practice, is not relevant.

    In addition, users can become unhappy when the sequence numbers are missing (which will ensure your suggested design). It matters little that they aren't really missing something, the numbers can make users think that documents are missing. It seems preferable to have consecutive sequence values in the tables (it can also tell you later if records have been deleted)

  • How to use the sequence of client web proxy.

    Hello

    I created a sequence in the database.

    And I'm sure in EntityImpl as:

    SequenceImpl sequence = new SequenceImpl ("Sequence_name", getDBTransaction);
    setAttribute (sequence.getSequenceNumber)

    I'll put the attribute with the val sequence automatically.


    But I want to get the value of the sequence in the web proxy client generated by WSDL.

    Right now, I'm writing the same code and imported files.
    But it gives me error that:

    java.lang.nullPointException.


    How to access the sequence in the web proxy client generated by WSDL.

    Hello

    expose a method on the ViewObject and make it available to the service interface. In the Web Services it is meaningless to create dependencies between a customer and the details of the implementation of the service.

    Frank

  • lighting of 3 leds using the sequence meal and time delay VI express?

    run the vi and a LED light, 1 second later, the 2nd led should light, 2 seconds later the 3rd led must light up then everything must stay on for 3 seconds, I need to use a flat sequence with 3 images and express time in each image

    Tips or advice would be grateful im a little new to this iv not been mess autour with her and to this day no luck

    Nevermind I got it

  • You want to sort the columns by using the ROLLUP GROUP.

    Want to order the below query using "column of News in descending order and the"Email address"column in ascending order.
    Note: Triage should not bring the total value at the top. It's happening now.

    {code}
    SELECT decode (grouping (NVL (customer, "NA")), 1, 'total', NVL (customer, "NA")) 'Email (ID). "
    "Location."
    Sum (News) "News."
    Sum (website) "Web Site",
    OF VW_FX_USERDATA
    GROUP BY ROLLUP (((NVL (Client, "NA")), location, 1, 'total', NVL (customer, "NA")))
    {code}

    Please let me know if you need any details.

    Published by: Nana Akkivalli on September 23, 2011 16:04
    order by decode(decode(grouping(NVL(EMailAddress, 'NA')),1, 'Totals', NVL(EMailAddress, 'NA')), 'Totals',2,1), 3 desc, 1 asc
    
  • How to use the clause type conditionally create new lines

    This question is just for learning - no object other than to start real world to create versions of some queries known to learn how to measure the performance of the MODEL clause clause of the MODEL versions.

    The question is: How can you write a STANDARD clause that pivots (updates) ONLY the lines that actually need to rotate and do NOT change the lines that have no value and cannot be rotated.

    I found a good site that has about two dozen example articles on different pieces. This first link is the beginning of the series.

    SQL features tutorials - Clause TYPE

    http://www.sqlsnippets.com/en/topic-11663.html

    This link is to a clause of FAQ of BluShadow MODEL version "how to convert rows to columns."

    Line - MODEL method string

    http://www.sqlsnippets.com/en/topic-11987.html

    The solution to this link uses this line of source:

    POSITION KEY VAL

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

    R08 0 v1, v2, v3,.

    and this result set:

    POSITION KEY VAL

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

    R08 1 v1

    R08 2 v2

    R08 3 v3

    The reason why it produces that result set is this clause of the statement of MODEL

    RETURN THE UPDATED LINES

    If you comment on this article, you will see that the original lines are all in position 0. This means that the solution reproduced EACH SOURCE LINE even if there is only one item in the list of values.

    Thus, even a line source with a single value (for example, the r01 'a') will be updated and updated this line is returned.

    For a large number of data sources with only a few lines that actually need to rotate it would be a great performance of infringement.

    This is the sample data source

    with t as (button 1, 'a' value 'abc' col2, col3 'def' of the double
    Select Union all 2, 'b', 'ghi', 'jkl' from dual
    Union all select 3, 'c, d, e, 'mno', 'pqr' from dual.
    Union all select 4, 'f', 'stu', 'vwx' from dual
    )
    Select the key, value, col2, col3
    t

    KEY, VALUE, COL2, COL3
    1, a, abc, def
    2, b, GHI, jkl
    3, "c, d, e, mno, pqr.
    4, f, stu, vwx

    Lines 1, 2 and 4 only have a value of (a, b, c respectively.

    Only line 3 must rotate. It contains "c, d, e" and which must become 3 lines in the result set

    Value of the key, col2 col3
    1 an abc def
    2B ghi jkl
    3 c mno, pqr
    3 d mno, pqr
    3 e mno, pqr
    4 f stu vwx

    The nut of the problem is that if the clause 'RETURN UPDATED ROWS' is used, then the lines 1, 2 and 4 must be updated in order to be returned in the result set. And if this clause is NOT used, then line 3 must be updated by 'c', d, e 'c' and two new product lines: one line for a ' and one for 'e '.

    How can you do this with the TYPE clause without the help of the clause "Return LINES UPDATE"? I don't have a solution to sample showing what I tried because I can't understand what it takes to even try.

    I have a solution that uses "RETURN UPDATED ROWS" but I want to compare this performance to the exercise, when this clause is NOT used.

    We ask BluShadow to add the solution of MODEL clause to this FAQ with other similar solutions.

    Like this?

    SQL > with t as
    () 2
    3 select the 1 key, 'a' val, 'abc' col2, col3 'def' of the double


    Select 4 Union all 2, 'b', 'ghi', 'jkl' from dual
    5 union all select 3, 'c, d, e, 'mno', 'pqr' from dual.
    Select 6 Union all the 4 'f', 'stu', 'vwx' from dual
    7)
    8. Select the key
    9, key_1
    10, val
    11, regexp_substr (val, ' [^,] +', 1, key_1) val_new
    12, col2
    13, col3
    14 t
    model 15
    16 partition by (key)
    dimension (1 key_1) 17
    18 measures (val, col2, col3, (length (val) - length (replace (val, ",")) + 1) as len)
    19 rules
    (20)
    21 val [for 1 to increment of len key_1 [1] 1] = val [1]
    22, col2 [for 1 to increment of len key_1 [1] 1] = col2 [1]
    23, col3 [for 1 to increment of len key_1 [1] 1] = col3 [1]
    24)
    25 order
    26 by key
    27, key_1;

    KEY KEY_1 VAL VAL_N NECK NECK
    ---------- ---------- ----- ----- --- ---
    1 1 has an abc def
    2 b 1 b ghi jkl
    3 1 c, d, e c mno pqr
    3 2 c, d, e d mno pqr
    3 3 c, d, e e mno pqr
    4 1 f f stu vwx

    6 selected lines.

  • Using the sequence @inlines - problems!

    Hello
    I'm having a problem with a paragraph that is wrapped in an "if" statement and that contains an inserted field.

    My paragraph begins:

    <? If@inlines:num=1? > blah blah blah... [DATE_OF_WITHDRAWL]... blah blah blah <? end if? >

    In fact, it looks like:

    <? If@inlines:num=1? > blah blah blah...
    01.03.2010
    .. .bla bla bla..? end if? >

    I tried the inlines sequence according to the thread: Re: how to avoid the line break in the loop if BI model publisher and have traversed the chapter:
    http://download.Oracle.com/docs/CD/E12844_01/doc/BIP.1013/e12187/T421739T481157.htm#con_freeform but still could not get my paragraph appear 'normal '.

    I would be very grateful for any advice on how to address this issue. Thank you
    Sue
    PS. I can now get the <? If@inlines:num=1? > work if I just want to add another piece of text in my paragraph according to the http://download.oracle.com/docs/cd/E12844_01/doc/bip.1013/e12187/T421739T481157.htm#con_freeform, but not when you insert a field.
    Thanks again!

    Published by: smp245 on March 8, 2010 12:11

    Hi Sue,

    I've corrected the template and sent you the pdf output as well. the error was that you had not updated the property formfield with the changes suggested by Charlotte. I've highlighted the formfield in grey content in the model (it will show the output correctly) this way you can easily see what had gone wrong.

    Good day

  • Remove the entire sequence of xml using the stylesheet

    I have just begun to develop with TestStand and its XML report generating functionality and managed to skip most learning hedges previously except for this one:

    I want to be able to remove an entire sequence (and all the sub-sub-activities/sequences below).  I created successfully filtering expressions in a report.xsl custom to remove "failed" a steptype specific tests.  However, removing all THE measures/actions that belong to a sequence of parent has baffled me.

    To illustrate, I have 3 sequences in my mainsequence file called 'Group A', 'Group B', Group C".  I have three different style sheets that will percolate one of these three groups.

    If the (unfiltered) gross output looks like this:

    Group A

    -Start the sequence group A

    -Step 1

    -Step 2

    -Sous-suite A1

    -Step 1

    Group B

    -Start the sequence group B

    -Step 1

    -Step 2

    -B1 sous-suite

    -Step 1

    Group C

    -Start the sequence group C

    -Step 1

    -Step 2

    -Sous-suite C1

    -Step 1

    I would like to be able to filter the xml so that it deletes the Group B entirely, as follows:

    Group A

    -Start the sequence group A

    -Step 1

    -Step 2

    -Sous-suite A1

    -Step 1

    Group C

    -Start the sequence group C

    -Step 1

    -Step 2

    -Sous-suite C1

    -Step 1

    I am extremely new to XML and XSL style sheets and how they interact with TestStand.  Is what I'm trying to do possible?  Like a relief, I suppose I could somehow tag each action in a sequence with the group that he runs sub - possibly by using a string in 'other results', but it would be very laborious and prone to error.

    Any guidance is appreciated.

    Thank you for your time,

    Matt

    SOLVED!

    Turn, the response was not as difficult as I thought.  The action to remove an entire sequence is actually not very different from remvoing one step 'failed' or 'NI_FLOW' steptype.

    The snippet for the solution is shown below and may be merged with anything that currently exists in your .xsl style sheet:

    function CheckIfStepSatisfiesFilteringCondition_node(node)
        {
           //ADD_STEP_FILTERING_CONDITION
           //Modify the filtering condition here to filter steps shown the report.
    
           //Grab the displayed step name
                 var stepName = node.selectSingleNode("Prop[@Name = 'TS']/Prop[@Name = 'StepName']/Value").text;
    
                 //Test if step name corresponds to sequence desired for removal ("Group B" in this example)
                 if (stepName=='Group B')
                   return false;
           return true;
         }
    

    If a step name never matches 'Group B', not only is removed from this row of the report, but all measures under this parent are also deleted.  It's exactly what I was describing in the op.

  • is it safe to use a view control of sequence to display the sequence file both for execution

    I have a Teststand UI written in Labview 2012.  It has a single control of sequence, and I use the ConnectSequenceView method to switch between the display just the loading sequence file and the running.  Allow me to reiterate.  When a file sequence is running, the control is connected to the execution Manager.  Otherwise, it is connected to sequenceFileView Manager.

    I begin to suspect that I have questions related to this control, when I do the following.

    1. load a movie file

    2 run Single Pass

    3. the execution ends

    4. unloading and Release sequence file

    5 load a different sequence file

    6. run single-pass

    7 Labview crashes

    Am I missing a step?

    Thank you

    Kevin

    So it seems the crash of Labview, I mentioned in the original post is unrelated to the joint use of display of the sequence control.  However during my troubleshooting, I noticed that I was missing cut from a point of view of control stage before connecting the other view.

    And for the record, I think that there are many things wrong with the architecture used in the complete example, but there also many too many features for what to.  Just need a simple "press a button" and "run a test" for operators.  Everyone uses the sequence editor.

    All right.  Thanks for the comments.

    Kevin

  • is there a way to impose the use of sequences

    is there a way to stop someone to insert an id without using the sequence?
    CREATE SEQUENCE id_seq
       START WITH 1;
    
    CREATE TABLE test_table (id_seq NUMBER (4) PRIMARY KEY);
    
    
    
    INSERT INTO test_table
         VALUES (id_seq.NEXTVAL);
    
    INSERT INTO test_table
         VALUES (2);
    
    INSERT INTO test_table
         VALUES (id_seq.NEXTVAL);
    gives us
    ORA-00001: unique constraint (DSAMSTRC. SYS_C0091648) violated
    as it should be

    However is it a check constraint of some ilk who made sure the user uses the sequence during inserts?
    then the second insert
    INSERT INTO test_table
         VALUES (2);
    gives me a sort of violation of check constraint that I do not use the id_seq. NEXTVAL?

    Allows you to encode the audit in a trigger

    SQL> ed
    Wrote file afiedt.buf
    
      1  create trigger trg_test_table
      2    before insert on test_table
      3    for each row
      4  declare
      5    l_currval integer;
      6  begin
      7    select id_seq.currval
      8      into l_currval
      9      from dual;
     10    if( l_currval != :new.id_seq )
     11    then
     12      raise_application_error( -20001, 'Hey!  Use the sequence' );
     13    end if;
     14* end;
     15  /
    
    Trigger created.
    
    SQL> INSERT INTO test_table
      2       VALUES (id_seq.NEXTVAL);
    
    1 row created.
    
    SQL> INSERT INTO test_table
      2       VALUES (id_seq.NEXTVAL);
    
    1 row created.
    
    SQL> INSERT INTO test_table
      2       VALUES (25);
    INSERT INTO test_table
                *
    ERROR at line 1:
    ORA-20001: Hey!  Use the sequence
    ORA-06512: at "SCOTT.TRG_TEST_TABLE", line 9
    ORA-04088: error during execution of trigger 'SCOTT.TRG_TEST_TABLE'
    

    But at this point, you're probably better just to have the trigger complete the sequence column ignoring all that was passed in.

    Justin

Maybe you are looking for

  • Can't connect to Pinterest

    I could not connect on Pinterest for a few weeks and am not in a position to determine what has changed since the last successful login. To enter the credentials in the login form and pressing on send, the page reloads to earthquakes Canada main page

  • Ways to iTunes that I have not installed

    Since the installation of win 10 I get "Download iTunes" whenever I try and download an application. I tried to uninstall and reinstalled iTunes without effect.  any suggestions plse

  • Problem creating recover DVD - Equium L350

    Please help, I just bought a L350 laptop and cannot create a recovery DVD.The writing of the DVD begins, and after 10-15 minutes the fails and I get the following message: The following question ccured while recoding data on the disk. A power calibra

  • pressure measurement

    I have a pressure sensor that generates the current signal. I want to connect it to the module NI 9205 to collect the signal. I already have a NI 9944 resistance totransfer from current to voltage signal. Could you tell me how to connect the transduc

  • Make sure that 'tour windows xp' appear again for a specific user

    When I create a new account, a little balloon appears in the bottom right of the screen next to the notification area that says 'Windows XP Tour'. After awhile, she disappears. Is it possible to bring it back and make it stay there all the time? How