Sequential Count of rows in a Column

Hi,
In a query, I have a table defined with the relevant detail required by the business. I need to insert a count into the first column so it identifies a unique number. e.g. row 1 = 1, row 2 = 2 etc.
How can this be done?

Further to this question, to clarify diagramatically what I'm trying to achieve is as follows:
Row Counter  | Header 2   |  Header 3  |  Header 4
1                     data               data           data
2                     data               data           data                    
3                     data               data           data
4                     data               data           data
I need to add the first column into my report but I don't know how to acheive this.
Can anyone assist?

Similar Messages

  • Count of rows from different Columns

    SELECT (SELECT COUNT (empno) empno
              FROM emp) empno, (SELECT COUNT (mgr) mgr
                                  FROM emp) mgr, (SELECT COUNT (sal) sal
                                                    FROM emp
                                                   WHERE sal > 2000) sal
      FROM DUAL;Hi friends
    Please let me know any better solutions for this query..??

    user10594152 wrote:
    Please let me know any better solutions for this query..??Why not just..
    SQL> select * from emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
    14 rows selected.
    SQL> ed
    Wrote file afiedt.buf
      1  select count(empno) as emps
      2       , count(mgr) as mgrs
      3       , sum(case when sal > 2000 then 1 else 0 end) as sals
      4* from emp
    SQL> /
          EMPS       MGRS       SALS
            14         13          6
    SQL>

  • Count the no. of rows in a column

    I want to count the no. of rows in APR_QTY column that are not equal to zero.
    SELECT DISTINCT
    SUPP_NAME,
    ITEM_NAME,
    (CASE WHEN BH_CAL_PERIOD=4 THEN TO_NUMBER(BI_QTY || '.' || BI_QTY_LS) ELSE 0 END)APR_QTY,
    (CASE WHEN BH_CAL_PERIOD=4 THEN BI_RATE ELSE 0 END)APR_RATE,
    (CASE WHEN BH_CAL_PERIOD=5 THEN TO_NUMBER(BI_QTY || '.' || BI_QTY_LS) ELSE 0 END)MAY_QTY,
    (CASE WHEN BH_CAL_PERIOD=5 THEN BI_RATE ELSE 0 END)MAY_RATE,
    (CASE WHEN BH_CAL_PERIOD=6 THEN TO_NUMBER(BI_QTY || '.' || BI_QTY_LS) ELSE 0 END)JUNE_QTY,
    (CASE WHEN BH_CAL_PERIOD=6 THEN BI_RATE ELSE 0 END)JUNE_RATE,
    (CASE WHEN BH_CAL_PERIOD=7 THEN TO_NUMBER(BI_QTY || '.' || BI_QTY_LS) ELSE 0 END)JUL_QTY,
    (CASE WHEN BH_CAL_PERIOD=7 THEN BI_RATE ELSE 0 END)JUL_RATE
    FROM
    OM_SUPPLIER,
    OM_ITEM,
    OT_BILL_HEAD,
    OT_BILL_ITEM,
    OT_BILL_ITEM_TED
    WHERE BI_BH_SYS_ID = BH_SYS_ID
    AND SUPP_CODE = BH_SUPP_CODE
    AND ITEM_CODE = BI_ITEM_CODE
    AND BH_SYS_ID = ITED_H_SYS_ID
    AND BI_SYS_ID = ITED_I_SYS_ID
    AND BH_TXN_CODE='SBRLRAW'
    GROUP BY BH_CAL_PERIOD,BH_TXN_CODE,SUPP_NAME,ITEM_NAME,BI_RATE,BI_QTY,BI_QTY_LS
    ORDER BY ITEM_NAME
    Message was edited by:
    yogeshyl

    Select sum(decode(apr_qty,0,0,1)) as cnt_apr_qty
    from ...

  • Calculating a count of rows where value matches another column value in the same table

    Hi,
    I'm struggling to do something in DAX that seems to me should be super easy (coming from a SQL world)!
    That is to count all rows in column 1 where the value matches the current value for column 1?
    E.g something like this:
    [Col2]=Count of rows in [Col1] where value = this.[Col1]
    Where the results are as in the table below:
    Col1, Col2
    A, 2
    A, 2
    B, 1
    Anyone?
    Martin Laukkanen
    Nearbaseline blog - nearbaseline.com/blog
    Bulk Edit and other Apps - nearbaseline.com/apps

    Thanks, that's perfect! 
    I knew it had to be something so simple, but after spending over an hour banging my head against those exact functions I couldn't get anything working!
    Martin Laukkanen
    Nearbaseline blog - nearbaseline.com/blog
    Bulk Edit and other Apps - nearbaseline.com/apps

  • Count the displayed date rows on a column.

    Hi,
    I am trying to have a table with the following information and try to give a total count (of the dates visible) at the bottom of the table for the date columns. (not counting the rows)
    (E.g.- Under the Sent column there are 5 dates displayed and there are 6 numbers associated. On the received column there are 3 dates displayed for 6 numbers)
    Could you please advice me how to accomplish this. Thank you in advance.
    Rob.
    Name SENum SentReceived
    John      1234     12/22/06     
         5678     12/13/06     
         6565     12/19/06     1/6/07
         5656 - -
    Jane     9866 12/18/06     1/5/07
    Jim     5657 12/18/06 12/14/06           
    Total:           5      3

    I ma not sue what you want but
    here is some idea at sql plus
    SQL> compute count of ename on deptno
    SQL> compute count of sal on deptno
    SQL> select deptno,ename,sal from emp order by deptno
      2  ;
        DEPTNO ENAME                                                     SAL
            10 CLARK                                                    2450
               KING                                                     5000
               MILLER                                                   1300
    count                                                       3          3
            20 SMITH                                                     880
               ADAMS                                                    1100
               FORD                                                     3000
               SCOTT                                                    3000
               JONES                                                    2975
    count                                                       5          5
            30 ALLEN                                                    1600
               BLAKE                                                    2850
               MARTIN                                                   1250
               JAMES                                                    1045
               TURNER                                                   1500
               WARD                                                     1250
    count                                                       6          6
               DEV                                                      5000
    count                                                       1          1

  • Column count doesn't match value count at row 1, unknown number of columns

    Hi,
    I am making a program to read data from excel files as the above and store them in tables. I have managed to read all the data from excel files as a string and store them in a table.
    ID Name Salary
    50 christine 2349000
    43 paulina 1245874
    54 laura 4587894
    23 efi 3456457
    43 jim 4512878
    But in my project I have several other files that have same cell that are blank as the above example
    ID Name Salary
    50 christine 2349000
    43 paulina
    laura 4587894
    23 3456457
    43 jim 4512878
    and when i ran the same program i get this exception :
    SQLException: Column count doesn't match value count at row 1
    SQLState: 21S01
    VendorError: 1136The code for creating the table and inserting the values is above:
    private static String getCreateTable(Connection con, String tablename,
                        LinkedHashMap<String, Integer> tableFields) {
                   Iterator iter = tableFields.keySet().iterator();
                   Iterator cells = tableFields.keySet().iterator();
                   String str = "";
                   String[] allFields = new String[tableFields.size()];
                   int i = 0;
                   while (iter.hasNext()) {
                        String fieldName = (String) iter.next();
                        Integer fieldType = (Integer) tableFields.get(fieldName);
                        switch (fieldType) {
                        case Cell.CELL_TYPE_NUMERIC:
                             str = fieldName + " INTEGER";
                             break;
                        case Cell.CELL_TYPE_STRING:
                             str = fieldName + " VARCHAR(255)";
                             break;
                        case Cell.CELL_TYPE_BOOLEAN:
                             str = fieldName + " INTEGER";
                             break;
                        default:
                             str = "";
                             break;
                        allFields[i++] = str;
                   try {
                        Statement stmt = con.createStatement();
                        try {
                             String all = org.apache.commons.lang3.StringUtils.join(
                                       allFields, ",");
                             String createTableStr = "CREATE TABLE IF NOT EXISTS "
                                       + tablename + " ( " + all + ")";
                             System.out.println("Create a new table in the database");
                             stmt.executeUpdate(createTableStr);
                        } catch (SQLException e) {
                             System.out.println("SQLException: " + e.getMessage());
                             System.out.println("SQLState:     " + e.getSQLState());
                             System.out.println("VendorError:  " + e.getErrorCode());
                   } catch (Exception e)
                        System.out.println( ((SQLException) e).getSQLState() );
                        System.out.println( e.getMessage() );
                        e.printStackTrace();
                   return str;
              private static void fillTable(Connection con, String fieldname,
                        LinkedHashMap[] tableData) {
                   for (int row = 0; row < tableData.length; row++) {
                        LinkedHashMap<String, Integer> rowData = tableData[row];
                        Iterator iter = rowData.entrySet().iterator();
                        String str;
                        String[] tousFields = new String[rowData.size()];
                        int i = 0;
                        while (iter.hasNext()) {
                             Map.Entry pairs = (Map.Entry) iter.next();
                             Integer fieldType = (Integer) pairs.getValue();
                             String fieldValue = (String) pairs.getKey();
                             switch (fieldType) {
                             case Cell.CELL_TYPE_NUMERIC:
                                  str = fieldValue;
                                  break;
                             case Cell.CELL_TYPE_STRING:
                                  str = "\'" + fieldValue + "\'";
                                  break;
                             case Cell.CELL_TYPE_BOOLEAN:
                                  str = fieldValue;
                                  break;
                             default:
                                  str = "";
                                  break;
                             tousFields[i++] = str;
                        try {
                             Statement stmt = con.createStatement();
                             String all = org.apache.commons.lang3.StringUtils.join(
                                       tousFields, ",");
                             String sql = "INSERT INTO " + fieldname + " VALUES (" + all
                                       + ")";
                             stmt.executeUpdate(sql);
                             System.out.println("Fill table...");
                        } catch (SQLException e) {
                             System.out.println("SQLException: " + e.getMessage());
                             System.out.println("SQLState: " + e.getSQLState());
                             System.out.println("VendorError: " + e.getErrorCode());
                   }To be more specific the error it in the second row where i have only ID and Name in my excel file and only these i want to store. The third row has only Name and Salary and no ID. How i would be able to store only the values that i have and leave blank in the second row the Salary and in the third row the ID? Is there a way for my program to skip the blanks as empty value?
    Edited by: 998913 on May 9, 2013 1:01 AM

    In an unrelated observation, it appears you are creating new database tables to hold each document. I don't think this is a good idea. Your database tables should be created using the database's utility program and not programmatically. The database schema should hardly ever change once the project is complete.
    As a design approach: One database table can hold your document names, versions, and date they were uploaded. Another table will hold the column names and data types. Another table can hold the data (type for all data = String). This way, you can join the three tables to retrieve a document. Your design will only consists of those three tables no matter how many unique documents you have. You probably should seek the advice of a DBA or experienced Java developer on exactly how structure those tables. My design is a rough layout.

  • Count of rows from different tables.

    Hi Friends,
    I have 4 tables with a common column name "ID". I would like to get the count of rows from all the four tables which has the same ID.
    Ex
    select count(a.id) from table1 a,table2 b,table3 c,table4 d where a.id=b.id=c.id=d.id=5;
    please suggest me some solution

    may be thsi?
    select count(a.id) from table1 a,table2 b,table3 c,table4 d
    where a.id=b.id and a.id=c.id and a.id=d.id and a.id=5;

  • Count of rows of a table in header

    Hi Experts,
    I am stuck in a tricky scenario.
    I need to get the count of rows of a table in a webi report in the header of the report.
    And the count should change dynamically according to the filtering done on the table.
    For eg.
    If I have 10 countries in a table, so table has 10 rows.
    Now the count on header should show 10.
    Now if we filter the column to 5 countries, the count on the header should change to 5.
    Any Idea's.
    Regards,
    Gaurav

    Nops
    It doesn't work.
    Let me reframe my issue again:
    I dragged country object on my report.
    UK
    US
    JAPAN
    CANADA
    Now lets say in the report title, I write the formula as =Count(country)
    It will give me 4.
    Now I clicked on the column country and applied filter i.e. country = US ; UK
    Now the block shows
    UK
    US
    In the header the cell still shows 4, which I want to see as 2.
    Any ideas....?
    Thanks
    Gaurav

  • Count MySQL rows based off Value in Dynamic Table

    Greetings all. I have 2 MySQL tables; 1 that contains the names of my classes.(Class A, Class, B, etc.) and 1 table that contains the names of students in each Class (for example Class A: John Doe; Class A: Susie Smith.; Class B: Jane Doe). In the 2nd table the Class name is in its own column and the student's name is in a 2nd column.
    I currently have a dynamic repeating table that lists the names of all of the classes from the 1st table. What I'm trying to do is add a second column to this repeating dynamic table that lists the number of students in each class. For example; Row 1 of the dynamic table would say "Class A | 5; Class B | 3; Class C | 7, etc.). The dynamic table works perfectly to list the class names. For the life of me I can't figure out how to perform a count for each class to insert in the repeating table. I will be adding more Classes which as why I'm trying to set up the counting query dynamically. So far I have only been able to figure out how to count the total rows in the 2nd table, or count the rows with a specified class name. Any advice or guidance on how to count the number of rows in the 2nd MySQL table based off the class name in the repeating table is much appreciated. Thank you for any and all help. Have a great day.

    Select count(*), Class from MyTable
    Group by Class
    Time to learn about SQL:
    http://www.w3schools.com/sql/sql_intro.asp

  • ABAP WD:  Count of rows using display_type_hierarchy in ALV

    Hi,
    I am trying to implement display_type_hierarchy in ALV and my requirement is to change the hierarchy based on user selection.
    I am able to get the hierarchy based on user selection. For ex: If there are 3 columns in ALV then user can choose the column in a dropdown box and see the hierarchy based on the chosen column. But I want to get the count of rows inside the hierarchy. I did not find any standard method for this. (Is there one?) Could you please let me know how to do it?
    Regards,
    Srini.

    G'day Anett,
    Did you manage to get an answer to this issue, we are trying to do the same thing.
    Cheers,
    Mick.

  • Print Row Numbers and Column Letters

    How do you tell Numbers to print the Row numbers and Column letters? This was very simple in Appleworks (print dialog box had that option). Can't find it in Numbers though.

    Here is a script doing all the job for us.
    Just select one or several cells in a table and run the script.
    It duplicates it, add an header row, an header column, insert the needed labels and fill the other cells with a formula grabbing the contents of the original table.
    --[SCRIPT build a table with headers]
    Enregistrer len tant que Script: build a table with headers.scpt
    déplacer le fichier créé dans le dossier
    <VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:Applications:Numbers:
    Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.
    Selectionner une cellule dans la table à dupliquer
    menu Scripts > Numbers > build a table with headers
    Le script duplique la table et crée des en-têtes de lignes et colonnes.
    --=====
    L'aide du Finder explique:
    L'Utilitaire AppleScript permet d'activer le Menu des scripts :
    Ouvrez l'Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
    Cochez la case "Afficher le menu des scripts dans la barre de menus".
    +++++++
    Save the script as Script: build a table with headers.scpt
    Move the newly created file into the folder:
    <startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
    Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
    Select a range of cells in the table to 'duplicate'
    menu Scripts > Numbers > build a table with headers
    The script duplicate the table and inserts columns/rows headers.
    --=====
    The Finder's Help explains:
    To make the Script menu appear:
    Open the AppleScript utility located in Applications/AppleScript.
    Select the "Show Script Menu in menu bar" checkbox.
    --=====
    Yvan KOENIG (VALLAURIS, France)
    2009/09/19
    --=====
    property theApp : "Numbers"
    --=====
    my activateGUIscripting() (* to be sure than GUI scripting will be active *)
    set {d_Name, s_Name, t_Name, r_Name} to my getSelection()
    if r_Name is missing value then
    if my parleAnglais() then
    error "No selected cells"
    else
    error "Il n'y a pas de cellule sélectionnée !"
    end if
    end if
    set new_Table to t_Name & "_#"
    my duplicateTable(s_Name, t_Name, new_Table)
    set delim to my getLocalizedDelimiter()
    (* grab localized function names and add an open parenthesis at end *)
    set IF_loc to my getLocalizedFunctionName("Numbers", "IF") & "("
    set CHAR_loc to my getLocalizedFunctionName("Numbers", "CHAR") & "("
    set INT_loc to my getLocalizedFunctionName("Numbers", "INT") & "("
    set MOD_loc to my getLocalizedFunctionName("Numbers", "MOD") & "("
    set INDIRECT_loc to my getLocalizedFunctionName("Numbers", "INDIRECT") & "("
    set ADDRESS_loc to my getLocalizedFunctionName("Numbers", "ADDRESS") & "("
    (* grab localized function names and add a couple of parenthesis at end *)
    set ROW_loc to my getLocalizedFunctionName("Numbers", "ROW") & "()"
    set COLUMN_loc to my getLocalizedFunctionName("Numbers", "COLUMN") & "()"
    tell application "Numbers" to tell document d_Name to tell sheet s_Name to tell table new_Table
    if column count = 256 then
    if my parleAnglais() then
    error "Oops, already 256 columns !"
    else
    error "Désolé, il y a déjà 256 colonnes !"
    end if
    end if
    if row count = 65536 then
    if my parleAnglais() then
    error "Oops, already 65536 rows !"
    else
    error "Désolé, il y a déjà 65536 lignes !"
    end if
    end if
    try
    add row above row 1
    on error
    if my parleAnglais() then
    error "Oops, already five header row !"
    else
    error "Désolé, il y a déjà cinq rangs d’en tête !"
    end if
    end try
    try
    add column before column 1
    on error
    if my parleAnglais() then
    error "Oops, already five header columns !"
    else
    error "Désolé, il y a déjà cinq rangs d’en tête !"
    end if
    end try
    set nbr to row count
    set nbc to column count
    (* =IF(COLUMN()<28,CHAR(COLUMN()63),CHAR(INT((COLUMN()-2)/26)+64)&CHAR(MOD(COLUMN()-2,26)65)) *)
    set theFormula to "=" & IF_loc & COLUMN_loc & "<28" & delim & CHAR_loc & COLUMN_loc & "+63)" & delim & CHAR_loc & INT_loc & "(" & COLUMN_loc & "-2)/26)+64)&" & CHAR_loc & MOD_loc & COLUMN_loc & "-2" & delim & "26)+65))"
    tell row 1
    repeat with c from 2 to nbc
    set value of cell c to theFormula
    end repeat
    end tell -- row 1
    (* =ROW()-1 *)
    set theFormula to "=" & ROW_loc & "-1"
    tell column 1
    repeat with r from 2 to nbr
    set value of cell r to theFormula
    end repeat
    end tell -- column 1
    (* =INDIRECT(ADDRESS(ROW()-1,COLUMN()-1,,,"Tableau 2")) *)
    set theFormula to "=" & INDIRECT_loc & ADDRESS_loc & ROW_loc & "-1" & delim & COLUMN_loc & "-1" & delim & delim & delim & quote & t_Name & quote & "))"
    repeat with r from 2 to nbr
    repeat with c from 2 to nbc
    set value of cell r of column c to theFormula
    end repeat -- with c
    end repeat -- with r
    end tell -- Numbers
    --=====
    Set the parameter delimiter which must be used in Numbers formulas
    on getLocalizedDelimiter()
    if character 2 of (0.5 as text) is "." then
    return ","
    else
    return ";"
    end if
    end getLocalizedDelimiter
    --=====
    on getLocalizedFunctionName(theApp, x)
    local p2bndl
    set p2bndl to (path to application support as text) & "iWork '09:Frameworks:SFTabular.framework:Versions:A:Resources:"
    return my getLocalizedName(theApp, x, p2bndl)
    end getLocalizedFunctionName
    --=====
    on getLocalizedName(a, x, f)
    tell application a to return localized string x from table "Localizable" in bundle file f
    end getLocalizedName
    --=====
    on getSelection()
    local _, theRange, theTable, theSheet, theDoc, errMsg, errNum
    tell application "Numbers" to tell document 1
    repeat with i from 1 to the count of sheets
    tell sheet i
    set x to the count of tables
    if x > 0 then
    repeat with y from 1 to x
    try
    (selection range of table y) as text
    on error errMsg number errNum
    set {_, theRange, _, theTable, _, theSheet, _, theDoc} to my decoupe(errMsg, quote)
    return {theDoc, theSheet, theTable, theRange}
    end try
    end repeat -- y
    end if -- x>0
    end tell -- sheet
    end repeat -- i
    end tell -- document
    return {missing value, missing value, missing value, missing value}
    end getSelection
    --=====
    on decoupe(t, d)
    local l
    set AppleScript's text item delimiters to d
    set l to text items of t
    set AppleScript's text item delimiters to ""
    return l
    end decoupe
    --=====
    on isItAsheet(s)
    try
    tell application "Numbers" to tell document 1
    count of tables of sheet s (*
    Post an error if s is not a sheet *)
    end tell
    return true
    on error
    return false
    end try
    end isItAsheet
    --=====
    on activateGUIscripting()
    tell application "System Events"
    if not (UI elements enabled) then set (UI elements enabled) to true (* to be sure than GUI scripting will be active *)
    end tell
    end activateGUIscripting
    --=====
    on duplicateTable(sourceSheet, sourceTable, newName)
    local lesFeuilles, lesTables1, found, listOfRows, cor, i, isSourceSheet, nameI, j, lesTables2
    tell application "Numbers"
    activate
    tell document 1
    set lesFeuilles to name of sheets
    if sourceSheet is in lesFeuilles then
    tell sheet sourceSheet to set lesTables1 to name of tables
    if sourceTable is not in lesTables1 then
    if my parleAnglais() then
    error "The sheet “" & sourceTable & "” of sheet “" & sourceSheet & "” is unavailable ! "
    else
    error "La table “" & sourceTable & "” de la feuille “" & sourceSheet & "” n'existe pas ! "
    end if
    end if -- sourceTable is not
    else
    if my parleAnglais() then
    error "The sheet “" & sourceSheet & "” is unavailable ! "
    else
    error "La feuille “" & sourceSheet & "” n'existe pas ! "
    end if
    end if -- sourceSheet is in
    end tell -- document
    end tell -- application
    if newName is not in lesTables1 then (*
    Now, an ugly workaround to duplicate the sheet *)
    set isOS4 to (system attribute "sys2") < 5
    tell application "System Events" to tell application process "Numbers"
    set docWindow to false (* CAUTION, an inspector ("AXFloatingWindow") or a Find/Search ("AXDialog") window may be open *)
    repeat with i from 1 to (count of windows)
    if subrole of window i is "AXStandardWindow" then
    set docWindow to i (* got the document's window *)
    exit repeat
    end if
    end repeat
    if docWindow is not false then
    tell outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window docWindow
    select row 1
    set value of attribute "AXFocused" to true
    set found to false
    set listOfRows to name of static text of every row
    set cor to count of rows (* equal count of listOfRows *)
    if isOS4 then (*
    for mac Os X 10.4.11
    CAUTION, listOfRows it's a list of lists !
    {{"Feuille 2"}, {"Tableau 1"}, {"theSheet"}, {"Feuille 1"}, {"Tableau 2"}, {"Clément"}, {"Feuille 4"}} *)
    repeat with i from 1 to cor (*
    Scan the thumbnails *)
    set nameI to item 1 of item i of listOfRows
    set isSourceSheet to (sourceSheet = nameI) and my isItAsheet(nameI)
    if isSourceSheet then
    select row i
    if (i < cor) and not my isItAsheet(item 1 of item (i + 1) of listOfRows) then (*
    Here we may scan the thumbnails of tables of sourceSheet *)
    repeat with j from i + 1 to i + (count of lesTables1)
    if sourceTable = item 1 of item j of listOfRows then
    select row j
    set found to true
    exit repeat
    end if -- sourceTable
    end repeat
    else
    if my parleAnglais() then
    error "The sheet “" & sourceTable & "” of sheet “" & sourceSheet & "”" & return & " is not revealed in thumbnails ! "
    else
    error "La table “" & sourceTable & "” de la feuille “" & sourceSheet & "”" & return & " n'est pas affichée dans les vignettes ! "
    end if -- my parleFrancais
    end if -- (i < cor)
    end if -- isSourceSheet
    if found then exit repeat
    end repeat -- i
    else (*
    for mac Os X 10.5.x
    CAUTION, listOfRows is a list of lists !
    {{}, {"Tableau 1"}, {"theSheet"}, {}, {"Tableau 2"}, {"Clément"}, {}}
    With 10.5.x, the names of sheets are empty *)
    repeat with i from 1 to cor
    set isSourceSheet to (class of UI element 1 of row i is group) and (get value of static text 1 of group 1 of row i) is sourceSheet
    if isSourceSheet then (*
    Here we may scan the thumbnails of tables of sourceSheet *)
    if value of UI element 1 of group 1 of row i is 0 then (*
    reveal the tables's thumbnails and adjust the list accordingly *)
    click UI element 1 of group 1 of row i (* click the black triangle to reveal tables *)
    delay 0.1
    set listOfRows to name of static text of every row (* update the list accordingly *)
    end if -- value of UI…
    repeat with j from i + 1 to i + (count of lesTables1)
    if sourceTable = item 1 of item j of listOfRows then
    select row j
    set found to true
    exit repeat
    end if -- sourcetable
    end repeat -- with j
    end if -- isSourceSheet
    if found then exit repeat
    end repeat -- with i
    end if -- check OS
    end tell -- outline …
    keystroke "d" using command down
    end if -- docWindow
    end tell -- System Events…
    if docWindow is not false then (*
    Rename the new table according to the passed name: newTable *)
    tell application "Numbers" to tell document 1 to tell sheet sourceSheet
    set lesTables2 to name of tables
    repeat with i in lesTables2
    if i is not in lesTables1 then (*
    Here i is the name of the newly created table *)
    set name of table i to newName
    exit repeat
    end if
    end repeat
    end tell
    end if -- docWindow
    end if -- newName is not…
    end duplicateTable
    --=====
    on parleAnglais()
    local z
    try
    tell application theApp to set z to localized string "Cancel"
    on error
    set z to "Cancel"
    end try
    return (z is not "Annuler")
    end parleAnglais
    --=====
    --[/SCRIPT]
    Yvan KOENIG (VALLAURIS, France) samedi 19 septembre 2009 17:33:59

  • How to convert Rows to different columns

    Hi All,
    I am having a table address with the following data.
    ID          REL_NAME     REL_RELATION  REL_PHONE
    1---          kish_rel1---     wife---     1111
    1---          kish_rel2---     sister---     2222
    1---          kish_rel3---     brother---     3333
    2---          ram_rel1---     brother---     4444
    Now i want to display rows data into columns. See the output i want. Exactly, I dont know how many rows are there for each ID. It may increase or decrease.
    ID          REL_NAME     REL_RELATION  REL_PHONE
    1---kish_rel1---     wife---     1111---kish_rel2---     sister---     2222---kish_rel3---     brother---     3333
    2---ram_rel1---     brother---     4444
    Thanks in advance,
    Pal

    Hi,
    I have found this is useful. But it is static. It wont work if we dont know the maximum number of rows present when grouped by ID.
    Is there any other solution, which will give correct values, if we dont know the row count when grouped by ID.
    SELECT hrid,
    MAX(case when seq=1 then rel_name end) AS "rel_name1",
    MAX(case when seq=1 then rel_relation end) AS "rel_relation1",
    MAX(case when seq=1 then rel_phone end) AS "rel_phone1",
    MAX(case when seq=2 then rel_name end) AS "rel_name2",
    MAX(case when seq=2 then rel_relation end) AS "rel_relation2",
    MAX(case when seq=2 then rel_phone end) AS "rel_phone2",
    MAX(case when seq=3 then rel_name end) AS "rel_name3",
    MAX(case when seq=3 then rel_relation end) AS "rel_relation3",
    MAX(case when seq=3 then rel_phone end) AS "rel_phone3",
    MAX(case when seq=4 then rel_name end) AS "rel_name4",
    MAX(case when seq=4 then rel_relation end) AS "rel_relation4",
    MAX(case when seq=4 then rel_phone end) AS "rel_phone4"
    FROM (SELECT hrid, rel_name, rel_relation, rel_phone, ROW_NUMBER() over(partition by hrid ORDER BY hrid) AS seq FROM address)
    GROUP BY hrid
    Thanks,
    Pal

  • How to get multiple records in one row and different column

    Hi All,
    I am using oracle database 11g
    and i have a two tables table_1, table_2
    table_1 having columns
    emp_no
    first_name
    middle_name
    last_name
    email
    and table_2 having columns
    emp_no
    phone_type
    phone_number
    and having entires
    emp_no phone_type phone_number
    1001 MOB 9451421452
    1001 WEMG 235153654
    1001 EMG 652341536
    1002 MOB 9987526312
    1003 WEMG 5332621456
    1004 EMG 59612356
    Now i want the output of values with phone type as MOB or WEMG in a single row with different columns
    emp_no first_name middle_name last_name email mobile officeno
    1001 mark null k [email protected] 9451421452 235153654
    1002 john cena gary [email protected] 9987526312 null
    1003 dany null craig [email protected] null 5332621456
    1004 donald finn sian [email protected] null null
    can i have any inputs to achive this???
    Regards
    $sid

    Frank Kulash wrote:
    sonething like this:Frank, you missed aggregate function (pivot requires one). However main thing is it will cause ORA-01748:
    with table_1 as (
                     select 1001 emp_no,'mark' first_name,null middle_name,'k'last_name,'[email protected]' email from dual union all
                     select 1002,'john','cena','gary','[email protected]' from dual union all
                     select 1003,'dany',null,'craig','[email protected] null' from dual union all
                     select 1004,'donald','finn','sian','[email protected]' from dual
         table_2 as (
                     select 1001 emp_no,'MOB' phone_type,9451421452 phone_number from dual union all
                     select 1001,'WEMG',235153654 from dual union all
                     select 1001,'EMG',652341536 from dual union all
                     select 1002,'MOB',9987526312 from dual union all
                     select 1003,'WEMG',5332621456 from dual union all
                     select 1004,'EMG',59612356 from dual
    SELECT     *
    FROM     table_1      t1
    JOIN     table_2      t2  ON  t1.emp_no = t2.emp_no
    PIVOT     (    max(t2.phone_number)
         FOR  t2.phone_type  IN  ( 'MOB'   AS mob
                                 , 'WEMG'  AS wemg
            FOR  t2.phone_type  IN  ( 'MOB'   AS mob
    ERROR at line 19:
    ORA-01748: only simple column names allowed hereYou need to:
    with table_1 as (
                     select 1001 emp_no,'mark' first_name,null middle_name,'k' last_name,'[email protected]' email from dual union all
                     select 1002,'john','cena','gary','[email protected]' from dual union all
                     select 1003,'dany',null,'craig','[email protected] null' from dual union all
                     select 1004,'donald','finn','sian','[email protected]' from dual
         table_2 as (
                     select 1001 emp_no,'MOB' phone_type,9451421452 phone_number from dual union all
                     select 1001,'WEMG',235153654 from dual union all
                     select 1001,'EMG',652341536 from dual union all
                     select 1002,'MOB',9987526312 from dual union all
                     select 1003,'WEMG',5332621456 from dual union all
                     select 1004,'EMG',59612356 from dual
         table_3 as (
                     select  t1.emp_no,first_name,middle_name,last_name,email,
                             phone_type,phone_number
                       FROM     table_1      t1
                       LEFT JOIN     table_2      t2  ON  t1.emp_no = t2.emp_no
    SELECT     *
    FROM     table_3
    PIVOT     (    max(phone_number)
         FOR  phone_type  IN  ( 'MOB'   AS mob
                                 , 'WEMG'  AS wemg
        EMP_NO FIRST_ MIDD LAST_ EMAIL                     MOB       WEMG
          1004 donald finn sian  [email protected]
          1003 dany        craig [email protected] null            5332621456
          1001 mark        k     [email protected]      9451421452  235153654
          1002 john   cena gary  [email protected]    9987526312
    SQL>SY.

  • Converting each row in a column to an XML

    Hi everyone,
    Using Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit
    I have a table where there is a comments column which is VARCHAR2. That column contains string data in the form of XML tags.
    Like for eg. *<tag_name attr_name="10"/>* (sorry cant provide the exact values as I'm not allowed to)
    There are many such rows. Now I want to use these strings and operate on them as XML like using XPath to find certain attributes etc.
    I tried using the extract function and to use it i need a XMLType object. So I tried to create one using the XMLType() constructor.
    But it gives me the error ORA-19032: Expected XML tag , got no content
    When I looked it up on the net, I found that this error number doesn't correspond to the error message that I'm getting. The error msg found on the internet was Expected XML tag string got string
    I used this query
    SELECT XMLType (<column>) FROM <table>;But when I modified it (based on someone's hunch) to
    SELECT XMLType (<column>)
      FROM <table>
    WHERE ROWNUM <= 1;The query worked fine. Like it can take only one row.
    I also tried like this
    SELECT XMLType ('<tag_name attr_name="10"/>')
      FROM DUAL;This too worked fine.
    So finally this has left me completely confused. Is there a way to convert every row in a column to an XMLType object so that I can use the extract function to gather information about it.
    For the time being I have used REGEXes to write the code. But having the flexibility of xml would be better.
    Any help would be appreciated.
    Regards,
    Arijit
    Edited by: Arijit Kanrar on May 23, 2013 5:27 AM

    Arijit,
    The error message is correct. What you found is merely the generic message with string placeholders.
    The error message is also pretty self-explanatory : you can't pass an empty string (NULL) to the XMLType constructor.
    SQL> select xmltype('') from dual;
    ERROR:
    ORA-19032: Expected XML tag , got no content
    ORA-06512: at "SYS.XMLTYPE", line 310
    ORA-06512: at line 1
    no rows selectedYou have to either add a WHERE clause to filter out NULL columns, or use a CASE statement to only convert strings that aren't empty :
    SELECT XMLType (<column>)
      FROM <table>
    WHERE <column> IS NOT NULL ;
    SELECT CASE WHEN <column> IS NOT NULL THEN XMLType (<column>) END
    FROM ...And do not use EXTRACT if you want to access scalar values, use EXTRACTVALUE instead :
    SQL> select extractvalue(xmltype('<tag_name attr_name="10"/>'), '/tag_name/@attr_name') from dual;
    EXTRACTVALUE(XMLTYPE('<TAG_NAMEATTR_NAME="10"/>'),'/TAG_NAME/@ATTR_NAME')
    10

  • On ALV report in1 column I want to put Icon on every row of that column.

    On ALV report there is 1 column I want to put Icon on every row of that column.That ALV program uses object oriented concept all class and methods.
      I want to use that icon on that row. That icon name is ‘ICON_OKAY’
    In my program when I assign values to internal table at that time I am assigning that ‘ICON_OKAY’ value to that row as follow.
    Itab-
    Itab-icon = ICON_OKAY.
    Append itab.

    please follow below procedure to display icon in ALV
    1) In corresponding fieldcatelog entry do
    fieldcatalog-icon = 'X'
    2) While filling the internal table fill the corresponding key value of icon , for example ICON_OKAY value is '@0V@' so statement would be
    Itab-icon = '@0V@'
    to get list of corresponding key for icon open include <ICON> in se38

Maybe you are looking for

  • Itunes 10.5 Install fail (win Vista 32bit)

    Hello everyone. I'm really frustrated why i can't complete the new update for itunes. I've had no problems with previous updates/installers. Check the picture below (it's in dutch). What should I do? I uninstalled itunes, maybe that should work for i

  • F-44 can't clear special GL

    under vendor 100001, there are two open items, all have special GL indicator:K, amount is the same 300 USD. when I use F-44 to clear vendor 100001, it reports error: Account 1100100 in company code  B100 cannot be directly posted to Message no. F5354

  • Hierarchy Settings at query level

    Hi, I my system Profit Center is compounded on Controlling Area. In Cube These are 2 different fields. I had a Profit Center Hierarchy that is being extracted from ECC...in the hierarchy The Profit center Key is a combination of Controlling Area + pr

  • EL in the "action" property of the button

    I am using ADFBC with JDeveloper 10.1.3.3 I have a scenario where by pressing on a button on a page, I want to be able to return to the originating page, and there are multiple originating pages. I can achieve this by putting the logic in the "action

  • Server 2012 DC behind NAT

    We have 2 sites, each with 2 domain controllers. The main site is with our servers in a hosted datacenter. We have an IPsec VPN tunnel setup between the sites, but the datacenter host does not add routes on their end for the tunnel. So the only way f