Unique number for each line of output

Hi experts,

I want a column that gives unique number in output.l can use rownum but the problem here is that I have two statements select with 'union' is not giving unique number. I am also a groupby clause.


I tried with row_number() also same results.

any help...

Thank you
KSS

Hello

Example usage of PEM:

SQL> select rownum, deptno, sal
  from (  select deptno, max(sal) sal
            from emp
        group by deptno
          having count( * ) > 2
        union
        select deptno, sal
          from emp
         where hiredate = (select min(hiredate) from emp))

    ROWNUM     DEPTNO        SAL
---------- ---------- ----------
         1         10       5000
         2         20        800
         3         20       3000
         4         30       1600

4 rows selected.

Concerning
Peter

Edited by: Peteron August 12, 2009 12:15 AM
-Dang, end again

Tags: Database

Similar Questions

  • Adding column which gives the serial number for each line in the Bulletin Board

    I use the update version 2 Jdev 11 g.
    I'm the filling of all employees from the emp table ADF table.
    My requirement is to add a column more as the first column and header line which displays the serial number for each serial number of row.the is not available in the table emp in database .i want to generate it dynamically when the data are filled in to ADF table.i don't want not to use the method to get the SQL query rownum. I want to get custom code (in the Managed Bean) or set all of the properties in the subject entity or any other object.

    Published by: sj0609 on September 8, 2009 09:43

    Hello

    Give an id to the table (say 'currRow') varStatus property. Add a column to the table (for example with a text output), then set it to the value of the output text #{currRow.index}.

    Arun-

  • NI-VISA takes a unique I.D. number for each USB device?

    Hi all

    I'm relatively new to LabVIEW and VISA Toolbox.

    When you communicate with LabVIEW and a USB via VISA, VISA shoots a D.I. unique number for the USB device for each connection established?

    I have reference: http://www.ni.com/white-paper/4713/en

    Kind regards

    Bryan

    Bryan,

    I don't understand what you're saying, so let me rephrase my answer and see that if this may help you - IF your device properly implements the USB standard and has a serial number, VISA uses this serial number.  If your device does not implement the USB standard correctly or if it does not have a serial number, VISA will do for you.

    If your device has a serial number, the VISA can be used to communicate with it.  There are routines that detect and identify VISA devices connected to your PC.

    JasonP

  • How to reset the value of line number for each header

    Hi all

    I need to reset the line number for each header values.

    create table header_table (header_value varchar2 (100));

    create table line_table (header_value varchar2 (100), number line_number);

    insert into header_table values ('ALAOF');

    insert into header_table values ('ALAOO');

    insert into line_table values('ALAOF',1);

    insert into line_table values('ALAOF',2);

    insert into line_table values('ALAOF',3);

    insert into line_table values('ALAOF',4);

    insert into line_table values('ALAOF',5);

    insert into line_table values('ALAOO,6);

    insert into line_table values('ALAOFO,7);

    insert into line_table values('ALAOO',8);

    insert into line_table values('ALAOO',9);

    insert into line_table values('ALAOO',10);

    insert into line_table values('ALAOO',11);

    insert into line_table values('ALAOO',12);

    Commit;

    TABLE HEADER_:

    header value

    ALAOF

    TRECYBEL

    LINE TABLE:

    header value line_number

    ALAOF 1

    ALAOF 2

    ALAOF 3

    ALAOF 4

    ALAOF 5

    TRECYBEL 6

    TRECYBEL 7

    TRECYBEL 8

    TRECYBEL 9

    TRECYBEL 10

    TRECYBEL 11

    TRECYBEL 12

    But looks like I got out of line below table

    LINE TABLE:

    header value line_number

    ALAOF 1

    ALAOF 2

    ALAOF 3

    ALAOF 4

    ALAOF 5

    TRECYBEL 1 <-reset the beginning of line number with 1 with different header value

    TRECYBEL 2

    TRECYBEL 3

    TRECYBEL 4

    TRECYBEL 5

    TRECYBEL 6

    TRECYBEL 7

    Please help me on this.

    Thanks in advance.

    Hello

    It makes no sense to do it in PL/SQL when you can do it with SQL.

    SQL is generally more efficient than PLSQL.

    And can you explain why you don't want to use analytical functions?

    This will update your table using a MERGE statement and an analytic function:

    MERGE INTO line_table lt
    USING
    (
       SELECT ROWID rid, header_value, row_number() OVER(PARTITION BY header_value ORDER BY ROWNUM) rn
         FROM line_table
    ) src
    ON (src.rid=lt.ROWID)
    WHEN MATCHED THEN
       UPDATE SET lt.line_number = src.rn;
    

    The result is less to:

    HEADER_VAL LINE_NUMBER

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

    ALAOF 1

    ALAOF 2

    ALAOF 3

    ALAOF 4

    ALAOF 5

    TRECYBEL 1

    TRECYBEL 2

    TRECYBEL 3

    TRECYBEL 4

    TRECYBEL 5

    TRECYBEL 6

    TRECYBEL 7

    Kind regards.

    Al

  • need to generate unique sequence for each transaction number

    need to generate unique sequence for each transaction number

    Use sometihng like that



    use the orcl: sequence-next function val

  • How do I either set channel name of a graph of cluster or get a 1 d waveform chart to start different time (t0) for each line of the waveform?

    I have a chart single 2D out a conditional of a loop indexing output such that over the rows of the table are not the same size. -Basically, they have different starting and ending points and sizes. -Not so concerned by the endpoints, because as soon as I get correctly starting points, everything shows fall in place.

    The challenge is that when I try to have the variable t0 (start time) for each line, the wave of construction vi form would always keep each line at the same starting point.

    I used the approach bundled with success (the cluster approach ensures that each waveform starts at different times according to the guidelines of my t0 defined for each line) but then I'm not able to get in the channel names I could make using the graphical approach (wave generation) waveform.

    In essence what I get here, I'm losing here.

    Because I don't want one of my mentors, Bob and Altenbach have fed up with me I have attached a vi this time

    Attached VI shows a combination of the two attempts (first with the waveform graph) and then with the graph of cluster

    1. with the first (graphical waveform), I get my channel names as you wish, but the alignment of the wave is not correct.

    2. with the second (graphical cluster), the alignment is good, but I can't do the names of channel in the chart, even if they are present in the cluster.

    I read some reviews that mentions that attributes can be displayed with waveform and data Dynamics (not clsuters) so I guess that's why.

    I saw another report indicating the start time for a waveform 1 d will always remain the same for the rest lines defined for the first line even if changed for the following lines in a loop.

    So I guess my question is: what is the way around questions like that?

    First of all, let me be the first to the congratulate and thank you for finally posting a code!  I'm not 100% certain I understand your question or your code, but I have an idea, perhaps, of what you want to do, so I wrote a little VI who made something simple that could be relevant.

    You mention waveforms of different lengths and beginning at different times.  You also want everyone to have a unique attribute (although I'm not sure what you want to do with the attribute).  So, I did the following:

    1. Generated an array of 100-sample random to represent one second of a waveform.
    2. Created 4 waveforms on this 100-sample basis.  The first waveform (channel 0) is just these 100 points.  The second, 1 channel, is the concatenation of string 0 with the base of 100 samples, or a waveform "double".  Channel 2 is 1 string concatenated with the base, and channel 3 is 2 string concatenated with the base.
    3. In order to trace the four channels that they rest 'on' the other, the waveform has the number of the channel added to it.  Channel 3 is 3 + (4 copies of the basis of 100 points), a waveform 400-point random centered around a shift of 3.
    4. All channels have dt value 0.01 (but I guess I could have varied, as well).
    5. To make the channels start at different times, I started channel N N seconds before channel 0 (by subtracting the index of the loop, I, T0).
    6. For each channel, I created an attribute called "Chan" equal to "Channel N" (where N = 0, 1, 2 or 3, as the case may be).

    This is the plot that results. Scale X is the absolute time value (no Date) using the 24-hour HH: mmS format.  You can see that the plots are 1, 2, 3 and 4 seconds of time, and are offset from each other by a second.  I used the trace attributes to change the name to the respective attribute.

    The code to do this is very simple - I almost don't need to show it, because I think it is completely described by the text above, but this is here:

    Now, it was not that much faster that some of your previous posts, when you refused to your postcode, "guess us" what you wanted (but not to not correctly guess), you tried to "push" us in the right direction (still refuses to post code), and no one seemed very happy?

    Bob Schor

  • number for each record that is extracted (query)

    Hello
    I want to what a number for each record that is retrieved from the recording which was released by this query

    For example
    For the first line/recored
    Number generated, ksnumber, date
    1, gg111 11/05/05
    2, oo235 06/12/05

    the query returned 2 records 1 and 2 are the number generated by this code.
    In addition if it is built in function, where in the code can I put it?


    < cfquery = name "gelov datasource ="kl90">"
    SELECT
    -------------------------------------------

    Of
    --------------------------------
    WHERE
    -----------------------------------------
    -----------------------------------------------------

    ORDER BY
    < cfswitch expression = "#Form.orderBy #" >
    < cfks value = "KSNUMBER" >
    KS. KS_NBR
    < / cfks >
    < cfks value = "DATECREATED" >
    KS. KREATDAT
    < / cfks >
    < / cfswitch >
    < / cfquery >

    <! - report html - >
    < cfswitch expression = "#Form.outputFormat #" >
    < cfks value = "HTML" >

    <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional / / IN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
    "< html xmlns =" http://www.w3.org/1999/xhtml "> "
    < head >
    < meta http-equiv = "Content-Type" content = text/html"; charset = iso-8859-1 "/ >"
    Report Kss Ctwye < title > < / title >
    < / head >
    < style type = "text/css" >
    table {}
    do-family: Arial, Helvetica, without serif.
    do-size: 10px;
    }
    TD {}
    do-family: Arial, Helvetica, without serif.
    do-size: 10px;
    }
    Th {}
    do-family: Arial, Helvetica, without serif.
    do-size: 10px;
    }
    H2 {}
    do-family: Arial, Helvetica, without serif.
    do-size: 12px;
    }
    H3 {}
    do-family: Arial, Helvetica, without serif.
    font-size: 13px;
    }
    < / style >

    < body >
    < cfoutput >
    < table border = "0" cellpadding = "3" cellspacing = "0" >
    < b >

    < td align = "center" >
    Kss Ctwye report < h3 > < / h3 > < br > < br > < table >
    < /tr >
    < b >
    < td align = "center" >
    < / h2 > report returned #getCtwyeKss.RecordCount # entries < / h2 > < table >
    < /tr >
    < b >
    < td >
    < table border = "1" cellpadding = "2" cellspacing = "0" >
    < b >

    < td width = "160" > Ks number < table >
    Date of creation of the < td > < table >
    <!-< class = 'dataField' td > address < table >
    < class td 'dataField' = > Type < table >
    < class td 'dataField' = >-> Description < table >
    < /tr >

    < cfloop query = "getCtwyeKss" >


    < tr bgcolor = "< cfif currentrow mod 2 > F8F8FF < cfelse > WHITE < / cfif >" >
    < td > #KS_NBR # < table >
    < td > #dateformat(KREATDAT,"mm/dd/yyyy") # < table >


    < /tr >
    < / cfloop >

    < /table >
    < table >
    < /tr >
    < /table >

    < / BODY >
    < / HTML >
    < / cfoutput >
    < / cfks >

    < cfks value = "CSV" >


    < NAME CFHEADER = "Content-Disposition" VALUE = "attachment; filename = ctwye.csv">
    < cfcontent type = "application/msexcel" > "Ks number", "Date of creation".
    < cfoutput query = "getCtwyeKss" > #ltrim (KS_NBR) #, "#dateformat(KREATDAT,"mm/dd/yyyy")" # "< tr #IIF (getCtwyeKss.CurrentRow MOD 2, OF (»), DE('backgroundColor="##999"')) # >"



    <!-< tr bgcolor = "< cfif currentrow mod 2 > # 808080 < cfelse > ##ffffff < / cfif >" >-->
    < / cfoutput >


    < / cfks >
    < / cfswitch >


    is not a Coldfusion tag. Use instead.

    The following code prints line numbers


    Select ksnumber, date
    from yourTable


    #currentrow #, #ksnumber #, #date #.

  • LabVIEW allows to read an Excel file to a control and add a checkbox for each line

    As say the topic, I need to use labview to read an excel file and show it in a control, such as mclb; I should add a checkbox for each line then allow me to choose the line I want. What should I do? Thank you very much.

    guiming wrote:

    I can read an Excel file to a spreadsheet, but I have no idea how to do to add a checkbox for each line.

    Sometimes, all you need to do is Google. https://decibel.NI.com/content/docs/doc-25000

    http://www.labviewing.com/check-box-in-multicolumn-ListBox/

  • How to access a column value in a Select list in a tabular presentation for each line

    Hello

    Environment: Using Oracle APEX v4.2.1 on an Oracle 11 g 2 DB

    In a tabular presentation using the following example query, i.e.:

    select
    "EMPNO",
    "EMPNO" EMPNO_DISPLAY,
    "ENAME",
    "HIREDATE",
    "SAL",
    "DEPTNO",
    "MY_LOV"
    from"#OWNER#"."EMP"
    
    

    I need access to every line of my sub form of table, the EMPNO of this line value, within a list of selection (query based LOV) in the column "MY_LOV."

    So, basically, the MY_LOV column in my table presentation, would be a list of selection (query based LOV) where MY_EMPNO =: EMPNO (first column in the select statement above), for each line of the tabular presentation.

    With the help of a picture ( Tom's Blog ) and assuming 'Deptno' column here is actually my new column, i.e. "MY_LOV, I want to know how this list of selection based on lov query would be able to access each EMPNO down in the form of tables, i.e. 7839, 7698, 7782 etc.?

    overview.png

    Any help would be appreciated.

    Thank you.

    Tony.

    Hi Tony,.

    Take a look at the API APEX_ITEM for LOV

    http://docs.Oracle.com/CD/E37097_01/doc/doc.42/e35127/apex_item.htm#AEAPI208

    Kind regards

    Brad

  • Use: OLD and: NEWS in the triggers without oracle for each line

    I use Oracle 10 g.
    I want to insert a row in the table of the newspaper by each Witch of the query is executed on a table.
    And I want to insert on the line at a table of detailed log for each row changed in a query.
    I want to add modification date and time for each line in the two tables of the newspaper and I want it to be similar.

    So, I'm curious about using old and new variables without using for each row on the creation of the trigger. Is this possible?
    Or maybe I can score some variables static for this query (so sysdate will be the same and some of the Pavilion for the insertion of small newspapers)?
    Or maybe is there other ways to do it?

    LeopoldStoch wrote:
    But if I use sysdate in each trigger and it will update something as my sysdate 100000 lines will be different for different lines but I want it to be time and on the same date.

    Hi Leopold,

    Then today is your lucky day :-): sysdate is the same for all the DML. Even if it takes more than one second:

    SQL> create table rob
      2  ( id int
      3  , creation_date date
      4  )
      5  /
    
    Table created.
    
    SQL> create trigger t
      2  before insert on rob
      3  for each row
      4  begin
      5          :new.creation_date := sysdate;
      6  end;
      7  /
    
    Trigger created.
    
    SQL> set timing on
    SQL> insert into rob (id)
      2   select level
      3     from dual
      4  connect by level <= 10000
      5  /
    
    10000 rows created.
    
    Elapsed: 00:00:00.37
    SQL> set timing off
    SQL> select min(creation_date)
      2       , max(creation_date)
      3    from rob
      4  /
    
    MIN(CREATION_DATE)  MAX(CREATION_DATE)
    ------------------- -------------------
    07-05-2010 09:29:24 07-05-2010 09:29:24
    
    1 row selected.
    

    You can read more here: http://rwijk.blogspot.com/2008/07/sysdate.html

    Kind regards
    Rob.

  • How to print 1 page for each line of the numbers worksheet

    Hello... I am trying to print reports of year-end per person and number.

    Is it possible in number to print 1 page for each row of a spreadsheet of numbers?

    Or suggestions?

    Thank you.

    Hi cm,

    This looks like a work of fusion and mailing.

    The merge document would create in Pages, and the cells of merger on this document référenceriez cells in the table in the document numbers.

    See the documentation Pages (on the Help menu) for instructions on the conduct of merger and mailing.

    To do this in only numbers, you would need to put in place a 'table of declaration' on a separate sheet (in the same document as the table containing information) which would accept a customer number (or other key ID for each individual) then use it to determine the line of the main table to retrieve information about this pattern.

    A more precise answer requires a more specific desription of your table structure and the desired form of the instruction to take.

    Kind regards

    Barry

  • How to maintain a sequence of number for each execution of the view

    Hi all

    I would like to implement a vision that returns the sequence number (say, at 1 and increment a (num = num + 1)) for each performance.

    for example, first, it should be 1 and then for the excution second it takes 2...

    What is the best way to implement this scenario?

    Please advice me...

    Thank you

    You cannot do it directly:

    SQL> create sequence s
      2  /
    
    Sequence created.
    
    SQL> create view s_view
      2    as
      3      select  s.nextval s_value
      4        from  dual
      5  /
        select  s.nextval s_value
                  *
    ERROR at line 3:
    ORA-02287: sequence number not allowed here
    

    You could:

    SQL> create or replace
      2    function s_func
      3      return number
      4      is
      5          v_retval number;
      6      begin
      7          select  s.nextval
      8            into  v_retval
      9            from  dual;
     10          return v_retval;
     11  end;
     12  /
    
    Function created.
    
    SQL> create view s_view
      2    as
      3      select  s_func s_value
      4        from  dual
      5  /
    
    View created.
    
    SQL>  
    

    However, sequence will be calculated that whenever view column is referenced:

    SQL> select  ename,
      2          s_value
      3    from  emp,
      4          s_view
      5  /
    
    ENAME         S_VALUE
    ---------- ----------
    MILLER              1
    CLARK               2
    KING                3
    ADAMS               4
    SMITH               5
    JONES               6
    FORD                7
    SCOTT               8
    JAMES               9
    MARTIN             10
    WARD               11
    
    ENAME         S_VALUE
    ---------- ----------
    ALLEN              12
    BLAKE              13
    TURNER             14
    
    14 rows selected.
    
    SQL>  select  ename,
      2           s_value,
      3           s_value
      4    from  emp,
      5          s_view
      6  /
    
    ENAME         S_VALUE    S_VALUE
    ---------- ---------- ----------
    MILLER             15         16
    CLARK              17         18
    KING               19         20
    ADAMS              21         22
    SMITH              23         24
    JONES              25         26
    FORD               27         28
    SCOTT              29         30
    JAMES              31         32
    MARTIN             33         34
    WARD               35         36
    
    ENAME         S_VALUE    S_VALUE
    ---------- ---------- ----------
    ALLEN              37         38
    BLAKE              39         40
    TURNER             41         42
    
    14 rows selected.
    
    SQL> 
    

    You could create the deterministic function, but it does not guarantee still sequence value will be calculated once per request.

    SY.

  • Put a unique number on each form is submitted

    My Department is new to Live Cycle Designer.  We created a PDF using LCD ES form that is used to approve the purchase of certain types of equipment.  I was prompted to change to include a unique identification number, and I need advice on where to start.

    The user goes on the web opens the PDF homologation form, fills out and clicks a button to send (on the form) that fits over the filled PDF an email that is sent to our office.  Once the form comes to us, it must be distributed to the other 4 or 5 oversight offices, and we want to identify each shape with a unique number, so we can monitor his progress.

    So what I was asked to do is to find a way to put a unique number generated automatically on the form at one point before it is emailed to us.  The number may have a number any numbers or characters (for as long as it is readable by humans) and does not need to be sequential.  I think a 5 or 6 digit would be good.

    I thought that the right approach would be to create a small Access database to generate/store identification numbers and then get the form of capture/read a new number every time that you click the submit button.  While I can connect to my database of test very well, what I do understand not how to execute SQL of LCD, or how to do it after the events, as when the form is opened or when the user clicks the submit button.  I didn't see any chance of finding similar good one so far.

    Is this the right way to go, or is there a better way to do it in LCD?

    Thanks for your time,

    -Max

    I created an example showing the various options that are available. Note that if you connect an external source such as a database and your users use player then you have to drive to extend the form using LiveCycle to allow this.

    The file that I was talking about is attached. If you need the process and controls for the DB I mention just ask and I'll post those as well. You will need LiveCycle server for this part.

    Paul

  • Remove the single record using the Recycle Bin for each line icon

    Hello

    Long ago, I saw in some blog ApEx showing how to remove records using "Trash" image on each line.
    I couldn't find that blog anywhere, but I managed to make an example.

    http://Apex.Oracle.com/pls/OTN/f?p=47888:5:0:no:

    Can you someone please guide me to good links on how to do the same.

    I appreciate for your time.

    Thank you
    Raj.

    Hello
    Here you are:

    http://Apex.Oracle.com/pls/Apex/f?p=19914:10:0:no:

    Best regards
    Fateh
    ------------------------------------------------------
    If you think that my answer was correct or helpful to you, then please check the response as helpful or appropriate.

  • connect by query, element need root for each line

    Hello

    I'm working on a hierarchical query using connection by front. Each node in the tree has two properties, a type and a sequence.

    The table that contains the hierarchy has 4 fields:
    element_type_from
    element_sequence_from
    element_type_to
    element_sequence_to

    Each child has a parent, a parent can have several childeren. For a map, the element_type_to and element_sequence_to fields are zero.

    To generate a tree, you can run:
    select element_type_to
    ,      element_sequence_to
    from   element_hierarchy
    start with element_type_from = [root_element_type]
           and element_sequence_from = [root_element_sequence]
    connect by prior element_type_to = element_type_from
           and prior element_sequence_to = element_sequence_from
    That works well... but... not only don't want child elements, I would like to return the sequence of element root for each child (in our table is a type of root element is always the same). There are several root elements and I want to create a list containing all the trees and each node in the tree must have its roots as well.

    There is the possibility to use sys_connect_by_path. This returns the root, but also the full path to the current child. It also returns a varchar2, requiring to be substr-ed and to_number-ed to get the sequence... not nice.

    warning, extremely ugly (but functional) code:
    select element_type_to
    ,      element_sequence_to
    ,      to_number(substr(sys_connect_by_path(element_sequence_from ,','),2,instr(sys_connect_by_path(element_sequence_from ,',') ||',',',',2)-2)) root_sequence
    from   element_hierarchy
    start with element_type_from = [root_element_type]
           and element_sequence_from = ( select [root_element_sequence] from all_root_elements )
    connect by prior element_type_to = element_type_from
           and prior element_sequence_to = element_sequence_from
    There must be something simple I'm missing here! Can you help me?

    Edit: Oops, the database version is 10.2.0.4.0

    CONNECT_BY_ROOT maybe?

Maybe you are looking for

  • Cannot get new url of the tab open with the homepage (Google).

    After the upgrade, I cannot get rid of 12 boxes (Facebook, Youtube, etc.) on the new tab or make open with my homepage (Google). I tried two different newtaburl add-on, uninstall and reinstall Firefox and the directives of the object: subject: config

  • If a .fcpbundle can be rebuilt? Question Archive:

    I have archived a FCPX project last year and I don't think that I did it correctly. It seems that I selected the .fcpbundle file and "has shown the contents of the package" and then copied all the content on my external hard drive for storage. Now I

  • Contacts and screen freezing savings?

    Is it possible to save a number to the list of contacts, once you finish the call if the number incoming or compound was not in your contacts before that? Sometimes my screen will freeze in horizontal mode, as if I had used with the keyboard. And as

  • VAIO PCG - 8112L

    OS: Windows Xp sp3 But I can't configure card driver And now I can't use for audio, microphone, webcam Help me, please! Thank you

  • Windows Update problems, error code: 0x802440oA

    I try to do the Windows updates to my XP pc and when I hit the express button it starts then stops and gives me an error code: 0x802440oA and custom allow updates. I had to do a complete restore of the system on my pc and need all the updates. Please