How to display the number of lines of time giving the values of the columns?

Hi all

I want to display the number of rows times the value exists in the column num in the query below


with t AS
   ( SELECT 'venkatesh' NAME, 'hyd' LOC, 2 NUM FROM DUAL
     UNION ALL
     SELECT 'prasad' NAME, 'hyd' LOC, 3 NUM FROM DUAL
     UNION ALL
     SELECT 'krishna' NAME,     'hyd' LOC, 1 NUM FROM DUAL )
  SELECT T.* FROM T
  CONNECT BY ROWNUM <= NUM


Expected output:

         venkatesh            hyd      2
         venkatesh            hyd        2
         prasad                 hyd        3
         prasad                   hyd      3
         prasad                   hyd      3
         krishna           hyd       1
Published by: Nag Aswadhati on November 1, 2012 12:34

Aswadhati NAG wrote:
Hi all

I want to display the number of rows times the value exists in the column num in the query below

Expected output:

venkatesh            hyd      2
venkatesh            hyd        2
prasad                 hyd        3
prasad                   hyd      3
prasad                   hyd      3
krishna           hyd       1

With the help of connection by: -.

with t AS
   ( SELECT 'venkatesh' NAME, 'hyd' LOC, 2 NUM FROM DUAL
     UNION ALL
     SELECT 'prasad' NAME, 'hyd' LOC, 3 NUM FROM DUAL
     UNION ALL
     select 'krishna' name,     'hyd' loc, 1 num from dual )
  select t.name, t.loc
  from t
  connect by level <= num
         and name = prior name
         and (prior sys_guid() is not null);

NAME      LOC
--------- ---
krishna   hyd
prasad    hyd
prasad    hyd
prasad    hyd
venkatesh hyd
venkatesh hyd 

 6 rows selected

Tags: Database

Similar Questions

  • How to display the columns in the wise line in pl sql

    I have to display some values of constant wise online using the select statement. For example, after query both display constant columnwise...

    Select 83: 42 double;

    83 42

    I want to display the rowwise... IE

    Constant
    83
    42

    I can create temporary table and add them then ask, but there should be a way I can use double to show the values line wise. something like

    Select a double where an in (83, 42)

    Appreciate your help.

    Hello

    Here's one way:

    SELECT     column_value    AS cnstnt
    FROM     TABLE (sys.odcinumberlist (83, 42))
    ;
    

    CONSTANT is a keyword from Oracle is not a very good name for your own column.

  • How to display the column single line with function of nested groups

    SQL > select deptno, Max (sum (sal)) SalSum
    2 of PEM
    3 Group of deptno;
    Select deptno, Max (sum (sal)) SalSum
    *
    ERROR on line 1:
    ORA-00937: not a single group group function

    Can you please help me to get the Max (sum (sal)) with Deptno...

    Or:

    select max(deptno) KEEP (DENSE_RANK LAST ORDER BY SalSum) deptno,
    max(SalSum) from  (
      select deptno,sum(sal) SalSum
      from emp
      group by deptno
    );
    
  • How to display the VM Workstation serial number

    I have 6 licenses for Workstation 6 and you just upgrades to version 7. I am trying to determine what user runs a number of series. I have 3 users right now and they have no idea who install package that they used. How to display the serial number for VM Workstation installed on a users computer.

    Thank you

    He stored in the Windows registry at the location following and Workstation 7 taking as example adjust you the path accordingly for the installed version.

    HKEY_LOCAL_MACHINE\SOFTWARE\VMware, Inc.\VMware Workstation\License.ws.7.0.e1.200904\Serial
    
  • How to display the result sqlplus in java?

    I want to call sqlplus to run some commands sql in java, but how can I print the result of sqlplus?

    In java code, I call sqlplus as:

    Process of p;
    Run the command
    p = Runtime.getRuntime () .exec (commandString);
    print the result of the command
    InputStream inputStream = p.getInputStream ();

    How to display the result of the execution?

    Published by: Yi on February 26, 2012 23:41

    You can use ProcessBuilder. Copy the following code starts sql * more and runs the script in the variable "filename". It displays the results in the console of NetBeans.

    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.io.File;
    import java.util.Map;
    
    public class test1 {
    
        public static void main (String args []) {
    
            test_script();
        }
    
        public static void test_script () {
    
            String fileName = "@test_table.sql";
            String sqlPath = "E:\\";
    
            String sqlCmd = "sqlplus";
    
            String arg1   = "user/password@sid"; -- plug in your user, password and db name
            String arg2   = fileName;
            try {
                String line;
                ProcessBuilder pb = new ProcessBuilder(sqlCmd, arg1, arg2);
                Map env = pb.environment();
                env.put("VAR1", arg1);
                env.put("VAR2", arg2);
                pb.directory(new File(sqlPath));
                pb.redirectErrorStream(true);
                Process p = pb.start();
              BufferedReader bri = new BufferedReader
                (new InputStreamReader(p.getInputStream()));
              BufferedReader bre = new BufferedReader
                (new InputStreamReader(p.getErrorStream()));
              while ((line = bri.readLine()) != null) {
                System.out.println(line);
              }
              bri.close();
              while ((line = bre.readLine()) != null) {
                System.out.println(line);
              }
              bre.close();
              System.out.println("Done.");
            }
            catch (Exception err) {
              err.printStackTrace();
            }
    
        }
    
    }
    

    Here is the content of the script at E:\\test_table.sql

    Prompt drop TABLE ANOTHER_TEST;
    DROP TABLE ANOTHER_TEST CASCADE CONSTRAINTS
    /
    
    Prompt Table ANOTHER_TEST;
    CREATE TABLE ANOTHER_TEST
    (
      BATCH_SEQ             NUMBER,
      BATCH_GROUP_ID        NUMBER,
      STATUS_FLAG           VARCHAR2(30 BYTE),
      OBJ_BEING_PROCESSED   VARCHAR2(80 BYTE),
      BATCH_RUN_START_DTTM  DATE,
      BATCH_RUN_END_DTTM    DATE,
      CREATE_DTTM           DATE,
      CREATE_USER           VARCHAR2(30 BYTE),
      UPDATE_DTTM           DATE,
      UPDATE_USER           VARCHAR2(30 BYTE)
    )
    LOGGING
    NOCOMPRESS
    NOCACHE
    PARALLEL ( DEGREE DEFAULT INSTANCES DEFAULT )
    MONITORING
    /
    
    COMMENT ON TABLE ANOTHER_TEST IS 'This is a test table.'
    /
    
    EXIT
    /
    
  • OBIEE answers how to display the menu drop-down

    Hello
    In answers how to display the name that we choose in the drop-down list on the report page

    and another thing is that I want to display the number of lines in the report as report salary has 20 lines, followed by the 20 lines in the report

    Waiting for your answer.

    Rgrds,
    Bala

    Published by: user13068446 on May 13, 2010 22:30

    create a report and save it.

    now, to create a line of dashboard your wish to keep as it's the default SNA record the prompt of the dashboard.

    now, go to the dashboard - options - section drag and report him.

    now do drag the guest to this article and put this promp above the report...

    Save it
    Now you can see the drop down prompt menu selected

    Concerning

    J Mama Prasad

  • How to display the rownum in oracle forms?

    Hai all,

    How to display the rownum in oracle forms?

    Thank you
    RCS
    ----------------

    I would add rowum with the current form of group_mstr:

    former columns:

    group_id
    GroupName

    new columns will be:

    identifier of the line
    group_id
    GroupName


    I created as follows:
    in forms
    text tool > row id
    text element > EXT_ITEM20

    error text element: no white color, it's a different color
    --------------

    create > Trigger > a time new form instance > I gave like this:

    DECLARE
    CURSOR crrow_id IS
    SELECT count (*) + 1 group_mstr;
    BEGIN
    OPEN crrow_id.
    Search FOR crrow_id IN: TEXT_ITEM20;
    CLOSE Crrow_id;
    END;
    ------------
    error: identifier group_mst must be declard
    ============

    I don't know also not quite what you want to display in your form. Do you want to just number the records displayed, from 1 to n?

    If so, create a text whose property 'data base element' element to the value 'no', "calculation method" formula and the formula itself: SYSTEM. " TRIGGER_RECORD, then, in each case, the registration number should be indicated.

  • How to display the list of components in ultiboard 10?

    The DRC report the errors where the components that are no longer in the design have been removed. How to display the list component and then remove them from the netlist to stop this?

    Ultiboard reported missing errors of component (part 'X' is not about design) because the part is always referenced by a net. To fix this, you must remove the part of the net. Following the steps below to remove the part form the net.

    1 tools > Netlist Editor

    2. for each network that the part has been connected to, select the Net (upper-left).

    3. Select the tab of pine trees, select the part and it is the PIN in the dialog box, then click on remove

    The problem is when the part is removed, I see no easy way to determine the threads you need to remove the part of. I entered this as a feature request to make this easier, but as a workaround, you can put part and say Ultiboard what the missing part, then search the net names on the pins and remove the part of these pins

    1 place a piece with a lot of pine trees (for example the part that was removed, or for example through Hole technology > Connectors > SIL & headers > HEADER2X9). When you place the part, make sure that the RefDes matches the RefDes of the part which has been removed.

    2. once the room is placed, you should see rats nest lines that connect the part to the nets.

    3 Zoom on the pins. You should now see the net name on each of the axes. For each of the pins connected, remove it from the net as described above.

    4. remove the part that you placed.

  • How to display the value of the variable for bottom of pl/sql

    How to display the value of the variable for bottom of pl/sql

    declare

    V_1 number: = 10;

    V_2 number: = 20;

    V_3 number: = 30;

    v_4 number: = 40;

    v_5 number: = 50;

    test varchar2 (100);

    Start

    I'm in 1.5

    loop

    test: = "v_" | I have;

    dbms_output.put_line(i||) e > ' | test);

    end loop;

    end;

    /

    How to get below output:

    1 > v_1

    2 > v_2

    3 > v_3

    4 > v_4

    5 > v_5

    But I want to output of

    1 > 10

    2 > 20

    3 > 30

    4 > 40

    5 > 50

    Hello

    You cannot reference variables as you did and get the value of the variable. Use pretty collection.

    set serveroutput on size 2000
    declare
      type      number_table is table of number;
      numbers   number_table := number_table(10, 20, 30, 40, 50);
    begin
      for i in numbers.first .. numbers.last
      loop
        dbms_output.put_line(i || '->' || numbers(i));
      end loop;
    end;
    /
    
    anonymous block completed
    1->10
    2->20
    3->30
    4->40
    5->50
    

    See the Collections of PL/SQL and Records http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/composites.htm#LNPLS005

  • How to display the parameter string registered by DBMS_XMLINDEX?

    This is probably a stupid question, but I can't seem to find any function to display the setting of a parameter string that was recorded by DBMX_XMLINDEX. REGISTERPARAMETER.

    For example,.

    If I have:
    BEGIN
    DBMX_XMLINDEX.REGISTERPARAMETER('indexParam', 'xxxxxxxx');
    END;
    /
    How to display the value of 'indexParam' after creation?
    SQL> set long 1000
    SQL>
    SQL> select paramstr
      2  from xdb.xdb$xidx_param_t
      3  where param_name = 'MYINDEXPARAM'
      4  ;
    
    PARAMSTR
    --------------------------------------------------------------------------------
    PATH TABLE po_ptab
        PATH ID INDEX po_pidx
        ORDER KEY INDEX po_oidx
        VALUE INDEX po_vidx
        PATHS(NAMESPACE MAPPING(xmlns:p="http://www.example.com/IPO"))
        GROUP MASTERGROUP XMLTABLE PO_TAB
        ('/p:PurchaseOrder'
            COLUMNS
               REFERENCE VARCHAR2(30) PATH 'p:Reference',
               REQUESTOR VARCHAR2(30) PATH 'p:Requestor' )
        GROUP ITEMGROUP XMLTABLE ITEMGROUP_TAB
        ('/p:PurchaseOrder/p:LineItems/p:LineItem'
            COLUMNS
               LINENUMBER NUMBER(38) PATH '@p:ItemNumber',
               QUANTITY NUMBER(38) PATH '@p:Quantity',
               DESCRIPTION VARCHAR2(256) PATH 'p:Description')
     
    

    After you add it to an index, you can also view the content in USER_XML_INDEXES. PARAMETERS (XML format).

  • How to display the serial No. field not to mention that the search results displayed

    How to display the serial No. field not to mention that the search results displayed

    Hello

    You missed to add the varstatus property in your table

    Try with this code:


    lines = ' #{bindings. " SahajDetailVO1.rangeSize}.
    emptyText = "#{bindings." SahajDetailVO1.viewable? "{'No data to display.': 'Access Denied.'}".
    fetchSize = "#{bindings." SahajDetailVO1.rangeSize}.
    rowBandingInterval = "0" id = "t1" styleClass = "AFStretchWidth."
    varStatus = 'vs' >



  • How to display the results in the order based on the value of research

    Hi all

    How to display the results in the slot order.
     
    
    CREATE TABLE TEST( SONGID  NUMBER, TITLE   VARCHAR2(200))
    
    INSERT INTO TEST(SONGID,TITLE) VALUES (10,'AHMADZAI, MIRWAIS (CA)/ MADONNA (CA)');
    INSERT INTO TEST(SONGID,TITLE) VALUES (11,'CICCONE, MADONNA (CA)');
    INSERT INTO TEST(SONGID,TITLE) VALUES (12,'DALLIN, MADONNA LOUISE/STOCK');
    INSERT INTO TEST(SONGID,TITLE) VALUES (13,'MADONNA');
    INSERT INTO TEST(SONGID,TITLE) VALUES (14,'MADONNA (A)/ AHMADZAI, MIRWAIS (C)');
    INSERT INTO TEST(SONGID,TITLE) VALUES (15,'MADONNA (CA)');
    INSERT INTO TEST(SONGID,TITLE) VALUES (16,'MIRWAIS AHMADZAI, MADONNA');     
    INSERT INTO TEST(SONGID,TITLE) VALUES (17,'MIRWAIS (CA)/ MADONNA (CA),AHMADZAI');
    INSERT INTO TEST(SONGID,TITLE) VALUES (18,'MADONNA (CA),CICCONE');
    
    SELECT *FROM  TEST WHERE INSTR (TITLE, 'MADONNA') > 0
    
    output: 
    SONGID     TITLE
    10     AHMADZAI, MIRWAIS (CA)/ MADONNA (CA)
    11     CICCONE, MADONNA (CA)
    12     DALLIN, MADONNA LOUISE/STOCK
    13     MADONNA
    14     MADONNA (A)/ AHMADZAI, MIRWAIS (C)
    15     MADONNA (CA)
    16     MIRWAIS AHMADZAI, MADONNA
    17     MIRWAIS (CA)/ MADONNA (CA),AHMADZAI
    18     MADONNA (CA),CICCONE
    
    Expected output :
    13     MADONNA
    14     MADONNA (A)/ AHMADZAI, MIRWAIS (C)
    15     MADONNA (CA)
    18     MADONNA (CA),CICCONE
    ..
    ..
    ..
    ..
    ...
    If the user makes a search with "MADONNA", I view the results as title begins with "MADONNA" first then the rest of the records.
    Please let me know is possible to show the results in this order.


    Kind regards
    Rajasekhar

    This can be a little more specific:

    SQL> SELECT *
      2  FROM   TEST
      3  WHERE  INSTR (TITLE, 'MADONNA') > 0
      4  ORDER  BY INSTR (TITLE, 'MADONNA')
      5           ,TITLE
      6  ;
    
                  SONGID TITLE
    -------------------- --------------------------------------
                      13 MADONNA
                      14 MADONNA (A)/ AHMADZAI, MIRWAIS (C)
                      15 MADONNA (CA)
                      18 MADONNA (CA),CICCONE
                      12 DALLIN, MADONNA LOUISE/STOCK
                      11 CICCONE, MADONNA (CA)
                      17 MIRWAIS (CA)/ MADONNA (CA),AHMADZAI
                      16 MIRWAIS AHMADZAI, MADONNA
                      10 AHMADZAI, MIRWAIS (CA)/ MADONNA (CA)
    
  • How to display the width of the page or the big screen in firefox 11 automatically?

    How to display the width of the page or the big screen in firefox 11 automatically? I know how to Ctrl +, ctrl - and ctrl 0, but is there a way to define 11 firefox to automatically set the page viewing by default "page width" or full screen (F11 not)?
    Help, please. Thank you.

    You can use an extension to set a page zoom and the size of the default font on the web pages.

  • How to display the drop-down list box in MS excel by using labview report generation toolkit? pleasepost code block diagram?

    How to display the drop-down list box in MS excel by using labview report generation toolkit? Please post the block diagram of the code so that I can able to generate from the drop-down list box in excel with the menu drop-down...

    Like this. (edition, use the reference forms instead of the reference to the worksheet)

    Ben64

  • How to display the name of my refnum on the front?

    I write data to a file. To do this, I use ' Open/create/replace the file' to prompt the user for a file name, which is then out of my VI as a refnum. I then write strings in this file with "write to a text file.

    How to display the name of the file (including the path) on the front panel once the user has entered it?

    Michael

    Use the Refnum at the path of e/s from file-> advanced file palette. You can wire it to a path indicator.

Maybe you are looking for

  • Colors of Safari are not

    Hi people, colors of Safari for Mac 10.11.2 9.0.2 Safari are not, the problem of the effects only Safari.  The displayed colors are pink, green and black, they resemble a color negative.  The photo is an example.  All started a long time ago after I

  • Problema in some hilos del foro

    Hola! I have a particular problem in some subforos. Yo generally luego leer los hilos uso opcion "todos como leidos easier", pero currently in el subforo 'Charlas Gnenerales' y ' series B y G ' me indican both 1 tema nuevo, pero cuando ingreso al for

  • Modbus master

    Hello I have a question about MODBUS/TCP. I have to write BITS of a register of exploitation. Unfortunally, operating records accept unsigned values (numbers). That's why I need to convert my binary value (for example 101000 > 5). But now I want to w

  • black screen empty after update of lollipop!

    My phone is: Z3 Compact Xperia After updating my phone from 4.4.4 android. Lollipop 5.0.2 I get a blank black screen of House, and I can't access anything in the phone except notifications and settings when scrolling from top.The 3 buttons below are

  • Lists of multiple contacts blackBerry Smartphones

    Me seems to currently have 3 occurrences of my Office on my BB contacts list, so I get 3 entries for most of my contacts and I get no name of the person when people call showing just the company name, very frustrating having to select the list of con