Sequence number for group of values in column

I need to create a sequnece number in a column starting from 5 and incremented by 5, based on values presenet in first column. If the value in first column changes then the sequence should start again with 5 and increment by 5.
for example: I want to generate the following output
Cat_code     Seq_No
1001          5
1001          10
1001          15
1001          20
2001          5
2001          10
2001          15
3001          5
3001          10
4001          5
4001          10
4001          15
4001          20
5001          5
6001          5
7001          5
7001          10
7001          15
7001          20
7001          25
So if the cat_code changes, the sequence number should again start from 5 and should be generate sequence number until the cat_code changes again.
any help apreciated.
Thanks
Rahul

Hi, Rahul,
You can use the analytic ROW_NUMEBR function to generate the numbers, like this:
SELECT       cat_code
,       5 * ROW_NUMBER () OVER ( PARTITION BY  cat_code
                                 ORDER BY        NULL
                     )       AS seq_no
FROM       table_x
ORDER BY  cat_code
,            seq_no
;You must use an analytic ORDER BY clause when you call ROW_NUMBER. If you don't really care about the order, then you can ORDER BY a constant, but you still need the analytic ORDER BY clause.

Similar Messages

  • How to execute a same sequence number for the resulting dynamic rows

    Hi friends,
    I have a sequence and trigger(which will fire id for each and every row insert).
    My scenario is, If i update more than 5 rows at a time means, i need to set a same sequence number example(1) for all the 5 rows.
    Next time, if i update another 5 rows means, then i need to set a same sequence number (i.e) 2 for the next 5 rows.
    So, my updation will be dynamic(may be 2 ,5, 10 rows at a time), But i need to set a same sequence number for one of the column for all the rows that i update.
    Next time, if i update another set of rows means, then i need to set only the next sequence number(i.e) 2(assume that previously updated sequence for the before set of rows is 1) for another set of rows.
    Like that sequence has to update in a sequential manner for more than one set of rows in that column.
    How to achieve it friends.
    example
    id-----------------name
    1-------------------A
    1-------------------B
    1-------------------C
    1-------------------D
    1-------------------E
    2-------------------D
    2-------------------E
    2-------------------F
    2-------------------G
    3-------------------H
    3-------------------IBrgds,
    Mini

    Hi,
    You forgot to mention your version.
    If you want a trigger based solution, then in 10g you need two triggers
    1. A statement level trigger that takes sequence.nextval into a dummy variable that will not be used.
    2. A for each row trigger that uses sequence.currval.
    In 11g you should be able to write a single, composite trigger.
    If you want a solution with no triggers, it could look something like
    SQL> create sequence s start with 10;
    Sequence created.
    SQL>
    SQL> create or replace function s_wrapped
      2  return number
      3  as
      4     v number;
      5  begin
      6     select s.nextval
      7     into v
      8     from dual;
      9
    10     return v;
    11  end s_wrapped;
    12  /
    Function created.
    SQL> create table tab1 as (Select level x, cast(null as number) y from dual connect by level <= 5);
    Table created.
    SQL> update tab1
      2    set y = (select s_wrapped from dual)
      3   where x <= 3;
    3 rows updated.
    SQL> commit
      2  /
    Commit complete.
    SQL> select *from tab1
      2  /
           X          Y
           1         10
           2         10
           3         10
           4
           5
    SQL>Regards
    Peter

  • Sequence number for opportunities

    Hello,
    My customer needs a sequence number for opportunities... So I can create a custom field but is there a way to automatic generate a number to fill it ? or for that matter a sequence ?
    Txs.
    Antonio

    Antonio, this functionality is not available at this time. This could be done using a custom web service program.

  • Screen Sequence number for MM01 T.Code

    Hi,
    Do we have any screen sequence for MM01 T.Code ? If Yes, Can you tell me the screen sequence number for MM01 and how to find it for other T.Codes also?
    Thanks in advance
    Pavan

    Hi,
    Follow this path
    SPROIMGLogistic generalMaterial masterConfiguring the Material MasterDefine Structure of Data Screens for Each Screen Sequence
    21 will be the u201CStd ind.(short) tab pagesu201D
    In this if you double click on u201CData screensu2019 in that u201CSub screensu201D if you click on that  you can find the all screen sequences for material master, program and screen number all you can find there
    Regards,
    Pramod

  • How to generate the batch number for group of records

    Hi All,
    requirement: i have created one sequence to generate the batch numbers.i have to get the nextval of the sequence for batch number (this column is not part of the table. its dynamic column/alias column) only for every 50000 records of a table.
    detail description:
    for example, if i have 10 records in a table. And, if i want to generate the batch number for every 2 records, then the output should look like belo.
    batch-number qty
    1 10
    1 20
    2 30
    2 40
    3 50
    3 60
    4 70
    4 80
    5 90
    5 100
    Please help me on this. Please let me know if you need more info.

    one more update on the above request. this has to be done using SQL query only.

  • Sequence Number for messages

    Hi,
    I need to implement a sequence number in the target structure for each time a message mapping is executed.
    As far as i can see on this forum and on sap.help.com it can be easily done with RFClookup inside the message mapping, and best implement something on abap-stack.
    I need to decide on using either a z-table or a number range and i need to decide whether to use PI abap stack or ECC abap stack.
    Any comments are useful.
    kr
    Robert

    Hi Bhavesh,
    I get interesting considerations on my question.
    It will be sequentially, almost for sure,  because i get this message via flatfile.
    Your second consideration is also interesting. Maybe the source can provide, maybe not (i'm not sure)
    Even more interesting if it is really necessary at the receiver side. This i actually asked the business, but still waiting for an answer. Meanwhile i just started looking around for the correct solution.
    kr
    Robert
    On second thought. It will be unique if i use number ranges with RFC lookup, because each number can only be used once.
    Edited by: R. den Hoedt on Mar 16, 2011 4:37 PM

  • Automatic sequence number for Inter-Org

    The problem which right now i am facing is that while making inter-org,... i am maintaining my own sequence... because system is not giving me any automated number... so due to this sometimes... sequence got disturbed... so is there any way.. that i can get the system generated sequence number.. as i am getting for sales order when i save it....if yes.. then please give me brief solution about this issue..
    Thanks,
    Junaid Iftikhar

    Hi,
    If you want your intercompany AR transactions to have a different numbering sequence from regular AR invoices, you need to setup a new transaction batch source for your interncompany AR transactions, a new order type and a new line type for your intercompany sales orders. When you define your order and line types, reference the new batch source you have just created in AR.
    AR Batch Source: AR Manager: Setup: Transactions: Batch Sources.
    Order an Line Type: OM Superuser: Setup: Transaction Types: Define.
    Hope it helps,
    Ketter Ohnes

  • How to generat sequence number for db in XSLT

    Hello SOA Gurus,
    I have a requirement, Please see below
    I am using SOA 11.1.1.6
    From a webservice call to db insert XSLT,  i have 10 elements at source side and 11 elements at target side.
    From source to target first 10 mappings are done.
    Now requirement is, for the 11th element in target- we need pass a sequence number to the targeted database, means---(sequence number has to be generated for every execution of XSLT execution)
    How to do the last point???
    Can anyone help me plzz

    Hi,
    You can pass the sequence number in the 11th element using "oraext:sequence-next-val("Sequence name as a string", "Datasource as a string") function.
    Regards,
    Anshul

  • How to print sequence number for a text item in a oracle reports

    Hi
    I have text item which repets for every round,if i have 3 or 4 rounds i should number the text item as 1,2,3,4 etc.... in a report.
    Can anybody help me
    Thanks in advance

    Hi Bob
    Thank you for your reply.
    Here is the data for example:
    Jobxxxx
    Round
    assembly for 3d $200 1 $200.00
    proof for 3d $10 3 $30.00
    Round
    plate for 3d $200 1 $200.00
    image for 3d $10 3 $30.00
    Job yyyy
    Round
    assembly for 3d $100 1 $100.00
    proof for 3d $50 3 $150.00
    So Bob everything is comming from tables except round.
    My question is how to add sequence number to round adn the result should be like this:
    Jobxxxx
    Round 1
    assembly for 3d $200 1 $200.00
    proof for 3d $10 3 $30.00
    Round 2
    plate for 3d $200 1 $200.00
    image for 3d $10 3 $30.00
    Job yyyy
    Round 1
    assembly for 3d $100 1 $100.00
    proof for 3d $50 3 $150.00
    Thank you in advance

  • Create Auto increment sequence number for list view report

    Hi All,
              Am using BAM 11.1.1.6 version, Have updating list report & wants to create auto increment sequence number at report level. Is it possible to create column at run time in BAM reports.
    Please help.
    Thanks.

    Hi All,
              Am using BAM 11.1.1.6 version, Have updating list report & wants to create auto increment sequence number at report level. Is it possible to create column at run time in BAM reports.
    Please help.
    Thanks.

  • How to get count of unique values of column B for each unique value of column A in Excel 2010?

    I have an excel sheet containing 72,000 rows in Excel 2010, column A is "site name", column B is category. I want a result that shows number of sites for each category.
    Column A Column B
    site 1 Category 1
    Site 1 Category 1
    Site 2 Category 1
    site 3 Category 2
    site 3 Category 2
    site 4 Category 2
    site 5 Category 2
    I want this result:
    Category 1    2
    Category 2    3
    I tried some formula in a 3rd column and created a pivot table on that column, but it did not give me the result i want.
    Any one has an idea ? what is the easiest way to achieve this?
    Appreciate any pointer

    I tried both formula referenced in these two post (I think they are a little simpler than the one above):
    http://stackoverflow.com/questions/11876238/simple-pivot-table-to-count-unique-values
    http://stackoverflow.com/questions/18898138/pivot-table-count-unique-values-excel-2010
    They both worked! and I got the result for my 72,000 rows!
    Thanks for your help!

  • How to get sequence number for tree level in tree table

    Hi,
    User would like to add a column as "Sequence" in the beginning of tree table. The tree table look like as following:
    Sequence Tasks Date
    1 ItemA
    subItem1 12/31/12
    subItem2 12/31/13
    subItem3 12/31/14
    2 ItemB
    subItem1 12/31/12
    subItem2 12/31/13
    subitem3 12/13/14
    How to add this sequence column in tree table?
    Thanks!
    Susan

    Check this sample:
    <af:form id="f1">
                    <af:treeTable value="#{bindings.Departments.treeModel}" var="node" styleClass="AFStretchWidth"
                                  columnStretching="last" selectionListener="#{bindings.Departments.treeModel.makeCurrent}"
                                  rowSelection="single" id="tt1">
                        <f:facet name="nodeStamp">
                            <af:column id="c1" headerText="Department Name" width="200">
                                <af:outputText value="#{node.index + 1} #{node.DepartmentName}" id="ot1"
                                               visible="#{bindings.Departments.treeModel.depth == 0}"/>
                            </af:column>
                        </f:facet>
                        <f:facet name="pathStamp"></f:facet>
                        <af:column id="c2" headerText="Employee Name">
                            <af:outputText id="ot4" value="#{node.FirstName} #{node.LastName}"/>
                        </af:column>
                    </af:treeTable>
                </af:form>Thanks,
    Navaneeth

  • IDOC to file: Increase sequence number for each item in a segment

    Dear All,
    I am having one scenario IDOC to file, where one IDoc with multiple items for an header in it will be sent.
    In Destination structure, for each iitem segment I am creating multiple rows. I have a field(INC_NUM) in target structure where in I have to start line number from 1 for each item.
    Also I have a condition - for item x or y I should only have the same line number.
    TinAdvance
    Swarna.
    Edited by: Swarna on Oct 24, 2011 8:15 AM

    Hello,
    You can use the statistic function called index for your requirement. Can you give sample input/output so that we can visualize further?
    Hope this helps,
    Mark

  • Determine Sequence Number for Full DR Restore

    According to Oracle’s documentation for performing a full DR using RMAN the following general steps need to be taken:
    1.     Restore the spfile.
    2.     Restore the controlfile
    3.     Set the ‘Set until sequence command’ –
    4.     restore database
    5.     recover database
    My question is how do you determine what to set the ‘until sequence’ to? Do you have to do this or will RMAN recover the database as far as it can and then you can issue the open database reset logs command?
    Thanks

    I am still a little confused.
    I know that I lost my current redo logs, I assume the production server is gone.
    How do I determine if I need to set the 'set until ' clause'
    I ran> list archivelog all;
    List of Archived Log Copies
    Key Thrd Seq S Low Time Name
    1883 1 1918 X 22-JUL-05 /orabkup/oraarc/edwdev_1_1918.arc
    1884 1 1919 X 22-JUL-05 /orabkup/oraarc/edwdev_1_1919.arc
    1885 1 1920 X 22-JUL-05 /orabkup/oraarc/edwdev_1_1920.arc
    1886 1 1921 X 22-JUL-05 /orabkup/oraarc/edwdev_1_1921.arc
    1887 1 1922 X 22-JUL-05 /orabkup/oraarc/edwdev_1_1922.arc
    I ran> list backup of archivelog all;
    BS Key Size Device Type Elapsed Time Completion Time
    903 599M SBT_TAPE 00:01:58 03-AUG-05
    BP Key: 903 Status: AVAILABLE Tag: INCR 1
    Piece Name: bk_uslgr4jl1_s917_p1_t565333665
    List of Archived Logs in backup set 903
    Thrd Seq Low SCN Low Time Next SCN Next Time
    1 2244 4136954621811 03-AUG-05 4136954623443 03-AUG-05
    1 2245 4136954623443 03-AUG-05 4136954796514 03-AUG-05
    Do I set the 'SET UNTIL SEQUENCE 2246 THREAD 1;' ?

  • What's the SAMTEC part number for J1 on TB-264x column connection board 191682B

    It the 66 pin right angle connector that plugs into J1 (SAMTEC FLE-137-01-G-DV-P-TR) on the Module Interface Board (192834 on the TB-2642).  It's 2 row 39 position with only 33 position filled so it must be a semi custom part?
    Thanks,
    Darrow
    Solved!
    Go to Solution.

    Hey Darrow,
    Are you familiar with the PXI-2531, which uses VHDCI connectors as breakouts instead of ribbon cables?
    This module is similar to the PXI-2532, but is only rated to 60VDC and doesn't support as many topologies as the 2532.  See the specification sheet for more info.
    This would prevent the design of such a cable. 
    If you do go through with the custom cable, make sure you provide sufficient strain relief.
    John Sullivan
    Switch Product Support Engineer
    National Instruments
    -John Sullivan
    Analog Engineer

Maybe you are looking for