How to count the fields with the bit data type

Hi friends,
I'm stuck in this report.
My responses as it looks.

region... offices... groups1... work2.
A..........a1............. 0..........1
A..........a2............. 1..........1
A..........a3............. 0..........0
B..........a1............. 1..........1
B..........a3............. 0..........0

Here 0 and 1 are values of bit (true and false)
I need to create a report that matter works if the value is true (1)
as...
Region... total_Work1... total_work2
A................... 1.............2
B................... 1.............1

and
Offices... Total_work1... Total_work2
a1............... 1.....................2
a2............... 1.....................1
a3.............. 0......................0

Please help me calculate this total when core values are few.

Thanks in advance

Hi Toony,

This is caused by internal database storage, a true is stored in the form of-1. Just take the integer ABS (absolute).

concerning
John
http://obiee101.blogspot.com/

Tags: Business Intelligence

Similar Questions

  • How to use the LOB data type?

    I can't create a table with the LOB data type.

    Do I need an additional parameter in sys.odbc.ini?

    My dsn information is

    [tpch]

    Driver=/home/TimesTen/TimesTen/tt1121/lib/libtten.so

    Data store = / home/timesten/TimesTen/tt1121/tpch/tpch

    LogDir = / home/timesten/TimesTen/tt1121/tpch/logs

    PermSize = 4096

    TempSize = 2048

    PLSQL = 1

    LOB = 1

    DatabaseCharacterSet = US7ASCII

    -bash-4, $ 1 ttdaemonadmin-version

    TimesTen Release 11.2.1.2.0

    There is no LOB = 1 attribute; Please, delete it from your definition ODBC to avoid potential errors.

    LOB support has been added in the major version 11.2.2 TimesTen. So you use 11.2.1 LOB is not available. If you want to use LOB data, then you must upgrade to 11.2.2.

    Chris

  • How to count the continuous dates in oracle 11g

    Hello

    I need to count the continuous more than 9 days between given dates below is my example

    Are my data like this
    MAY 1, 2013
    MAY 2, 2013
    MAY 3, 2013
    MAY 4, 2013
    MAY 5, 2013
    6 MAY 2013
    MAY 7, 2013
    MAY 8, 2013
    MAY 9, 2013
    MAY 10, 2013

    Now I want the number of days between these continuous days of more than 9 days now, I will get the result for the above data is 10 days
    If any date is not in the list then days would not result if it is less, then are equal to 9 days
    Here is an example of another
    MAY 1, 2013
    MAY 2, 2013
    MAY 3, 2013
    MAY 4, 2013
    MAY 5, 2013
    6 MAY 2013
    MAY 7, 2013
    MAY 8, 2013
    MAY 10, 2013
    11 MAY 2013

    number of days here is 10 but may 9, 2013 is away at the moment, the county should not show as 10 because continuous date (May 9, 2013) is absent, that's what I need, please suggest the solution.

    using the {: identifier of the thread = 1005478}

    SQL> ed
    Wrote file afiedt.buf
    
      1  with test as
      2  (
      3  select date '2013-5-1' dt from dual union all
      4  select date '2013-5-2' dt from dual union all
      5  select date '2013-5-3' dt from dual union all
      6  select date '2013-5-4' dt from dual union all
      7  select date '2013-5-5' dt from dual union all
      8  select date '2013-5-6' dt from dual union all
      9  select date '2013-5-7' dt from dual union all
     10  select date '2013-5-8' dt from dual union all
     11  select date '2013-5-9' dt from dual union all
     12  select date '2013-5-10' dt from dual union all
     13  select date '2013-5-11' dt from dual union all
     14  select date '2013-5-13' dt from dual union all
     15  select date '2013-5-14' dt from dual union all
     16  select date '2013-5-15' dt from dual union all
     17  select date '2013-5-16' dt from dual union all
     18  select date '2013-5-17' dt from dual
     19  )
     20  select min(dt),max(dt),count(*)
     21  from (select dt,
     22        dt-Row_Number() over(order by dt)
     23        as disTance
     24        from test)
     25  group by disTance
     26* order by min(dt)
    SQL> /
    
    MIN(DT)   MAX(DT)     COUNT(*)
    --------- --------- ----------
    01-MAY-13 11-MAY-13         11
    13-MAY-13 17-MAY-13          5
    
  • How to join two fields with slightly different data

    I have two columns, I need joined, both keep the columns of numeric data, but are of type varchar2 (6). The problem is that one of the columns keeps leading zeros to ensure that all 6 characters are used, but not the other. And columns preserve leading zeros may vary how many zeros are in the number-based computing.

    For example, the column with zeros can contain the number 4200, which would mean that he would remain with 2 zeros as 004200. Or it could contain 320, which means that he would remain with 3 zeros as 000320.

    The other column that does not have leading zeros not only keeps the number, so, in the example above, it would keep 4200 and 320 respectively.

    Can someone help on how to join these columns so that they match? I guess I have to delete the zeros in one or add zeros in the other? I tried to use the trunc with zeros on the ground, but it did not work...

    The following sql code:

    M06.mbr06_prv_id has no zeros, prv647.provider_id zeros. See bold below...

    SELECT
    M06.mbr06_prv_id,
    prv647.Site_ID
    Of
    Odw.mbr06_mbr_elig m06
    JOIN THE
    Odw.prv647_prov_exp prv647
    WE
    M06.mbr06_prv_id = prv647.provider_id
    WHERE
    M06.mbr06_subs_id = "999999999 '

    BTW, I have no control on how this data is represented in a table... !

    Hello

    user12296489 wrote:
    ... I guess I have to delete the zeros in one or add zeros in the other?

    Yes, this is how I see.
    LTRIM removes given characters from the beginning of a string. LPAD adds characters at the beginning of a string. I would use LTRIM in this case, because if you use LTRIM, you probably need to handle a single column. If you use LPAD, you have to play with the two columns, as one of them still has the extra 0, and it sometimes needs them.

    I tried to use the trunc with zeros on the ground, but it did not work...

    TRUNC is working on the kinds or DATEs; you have VARCHAR2s. You can convert them to numbers, but then you risk of errors to cause bad data (and it linked to the wrong data).
    >

    The following sql code:

    M06.mbr06_prv_id has no zeros, prv647.provider_id zeros. See bold below...

    SELECT
    M06.mbr06_prv_id,
    prv647.Site_ID
    Of
    Odw.mbr06_mbr_elig m06
    JOIN THE
    Odw.prv647_prov_exp prv647
    WE
    M06.mbr06_prv_id = prv647.provider_id
    WHERE
    M06.mbr06_subs_id = "999999999 '

    If you are certain that m06.mbr06_prv_id never has extra characters, whereas the join condition can be

    ON   m06.mbr06_prv_id   = LTRIM ( prv647.provider_id
                                      , '0'
                           )
    

    If this isn't the case, CUT then the two columns.

    BTW, I have no control on how this data is represented in a table... !

    Report a bad design is for people who don't have not this control. Numbers are the number of columns, not VARCHAR2. If the ID really needs to be strings, they should be validated and standardized once, when they are placed in the table, no more, and more, in all queries that use these columns.

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all tables and also post the results desired from these data.
    Explain, using specific examples, how you get these results from these data.
    Always tell what version of Oracle you are using.

  • How to select individual fields defined in a data type?

    Hello

    I used SQL in the database, but I'm new to most of the features of Oracle. I was reading the book Oracle SQL * more: definitive guide and came across the following tables defined as stated:

    SQL > describe employees

    < pre >
    Name Null? Type
    ----------------------------------------- -------- ----------------------------

    NUMBER OF EMPLOYE_ID
    EMPLOYEE EMPLOYEE_TYPE
    < / pre >

    The employee field is a structured type named 'EMPLOYEE_TYPE' defined as

    < pre >
    SQL > describe employee_type

    Name Null? Type
    ----------------------------------------- -------- ----------------------------

    EMPLOYEE_NAME VARCHAR2 (40)
    DATE OF EMPLOYEE_HIRE_DATE
    EMPLOYEE_SALARY NUMBER (9.2)
    < / pre >

    I wanted to select just the employee_name and tried what is obvious

    Select employee.employee_name employees;

    also tried

    Select employee_type.employee_name employees;

    but none worked. I tried every variation I could think of, searched an answer using google, still do not find the answer.

    I'd greatly appreciate to have the answer. It is probably simple, but really, it escapes me at the moment.

    Thank you very much for your help,

    John.

    Published by: user2652839 on July 8, 2010 14:38

    You must use the function TREAT

    SQL> create or replace
      2  type EMPLOYEE_TYPE
      3  as object (EMPLOYEE_NAME VARCHAR2(40),
      4  EMPLOYEE_HIRE_DATE DATE,
      5  EMPLOYEE_SALARY NUMBER(9,2)
      6  );
      7  /
    
    Type created.
    
    SQL> create table employees(EMPLOYEE_ID NUMBER,EMPLOYEE EMPLOYEE_TYPE)
      2  /
    
    Table created.
    
    SQL> insert into employees
      2  select empno,EMPLOYEE_TYPE(ename,hiredate,sal) from emp
      3  /
    
    14 rows created.
    
    SQL> select employee.employee_name from employees;
    select employee.employee_name from employees
           *
    ERROR at line 1:
    ORA-00904: "EMPLOYEE"."EMPLOYEE_NAME": invalid identifier
    
    SQL> select treat(employee as EMPLOYEE_TYPE).employee_name from employees;
    
    TREAT(EMPLOYEEASEMPLOYEE_TYPE).EMPLOYEE_
    ----------------------------------------
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    
    TREAT(EMPLOYEEASEMPLOYEE_TYPE).EMPLOYEE_
    ----------------------------------------
    KING
    TURNER
    ADAMS
    JAMES
    FORD
    MILLER
    
    14 rows selected.
    
    SQL> 
    

    SY.

  • convert the varchar2 data type to the data number type

    How to convert the varchar2 data type to the data type number.


    It looks like my data

    create table one)
    col1 varchar2 (50)
    col2 varchar2 (500);

    Insert in a (col1, col2) values ('1234 ', ' 2345');

    Select Column1 of number (19)) cast (to_number (col1);

    IAM getting error invalid number


    I need to create a table with the same columns with data like number types (19)

    can someone help me

    Thank you

    You have changed your original post, so now I see that you get the invalid number.

    This is why you should always avoid the varchar columns to store numbers or dates...

    Since your table source contains a nonnumeric value, you can write a pl/sql to convert data and see what records are false:

    SQL> insert into a (col1,col2) values ('xxxx','2345');
    
    1 row created.
    
    SQL> select * from a;
    
    COL1     COL2
    -------- --------
    1234     2345
    xxxx     2345
    
    2 rows selected.
    
    SQL> create table b (col1 number(19), col2 number(19));
    
    Table created.
    
    SQL> set serverout on
    
    SQL> declare
      2  cursor c is
      3  select * from a;
      4  begin
      5    for r in c loop
      6     begin
      7       insert into b values (to_number(r.col1), to_number(r.col2));
      8     exception
      9       when invalid_number then
     10        dbms_output.put_line('Row rejected: col1='||r.col1||' col2='||r.col2);
     11     end;
     12    end loop;
     13  end;
     14  /
    Row rejected: col1=xxxx col2=2345
    
    PL/SQL procedure successfully completed.
    
    SQL> select * from b;
    
          COL1       COL2
    ---------- ----------
          1234       2345
    
    1 row selected.
    

    Max

    Published by: Massimo Ruocchio, June 14, 2011 20:00
    Added the first query in the example

  • How to count the page that is provided on page element

    How to count the page that is provided on page element

    Hi durgeshj41842015,

    the kDocBoss has an IPageList interface with GetPageCount() function.

    Markus

  • How to count the number of elements in a data block

    Hi all
    How to count the number of elements in a particular data block oracle Forms 10g.
    If it's a text_item or the display_item or the list_item etc is there any method to do this.

    Please answer...

    get the first element with GET_BLCOK_PROPERTY(..., FIRST_ITEM);
    loop until GET_ITEM_PROPERTY(..., NEXTITEM) is null
    count on in the loop.

  • How to count the number of data records?

    Hey guys, how to count the number of records, I had on a data object variable?

    Im having a result of sql query in a variable like this:

    oDB.resolveNode("#command").query.select.value = "SELECT * FROM Customers WHERE CliNombre LIKE ' % ' + input1 +" %' ";

    oDB.open ();

    oDB.first ();

    So I need to count the number of records retrieved by this SQL query at the moment. Help please

    Then move the cursor back to the first record after you have your account.

    There is a keyword count in SQL that will allow you to get the account of your request. You can run that first - get your account, and then run the actual query to get the Recordset. This would require a separate data connection. Some examples of code.

    var xfa.event.newText = inName;
    If (inName == "") {}
    App.Alert ("you must enter a name--try again!")
    }
    var nIndex = 0;
    While (xfa.sourceSet.nodes.item (nIndex) .name! = "DataConnection2")
    {
    nIndex ++;
    }

    oDB = xfa.sourceSet.nodes.item (nIndex) .racing var (1); pertaining to the specified data connection node
    App.Alert (ODB.saveXML ("Pretty"));

    var nIndex = 0;
    While (xfa.sourceSet.nodes.item (nIndex) .name! = "DataConnection3")
    {
    nIndex ++;
    }
    var oDBCount = xfa.sourceSet.nodes.item (nIndex) .racing (1); pertaining to the specified data connection node
    Configure sql call DB to get the number of records that match the criteria

    oDBCount.nodes.item (1).query.setAttribute ("text", "commandType");
    oDBCount.nodes.item (1).query.select.nodes.item (0) .value = "Select count (*) from table1 where AcctNumber = '" + inName + "'";
    oDBCount.open)
    oDBCount.close)

    Configure sql call DB to get the specified employee number

    oDB.nodes.item (1).query.setAttribute ("text", "commandType");
    oDB.nodes.item (1).query.select.nodes.item (0) .value = "Select * from table1 where AcctNumber = '" + inName + "'";
    App.Alert (ODB. Nodes.Item (1) .saveXML ("Pretty"));

    now connect to the DB and get a recording
    oDB.open)
    oDB.close ();

    Note the SQL command use the keyword count (take a look at the oDBCount section). This will return a number of return to the cllaer. When I set up the data connection, a node count (*) that appeared there. I dragged to the form and it has created a field called count that the onus at this node. When the query is executed, the number of resulting records returns to this field. You can have hidden it so that your users can not see it and also to change the binding votes to zero, so it is not included in the data file that is submitted when the form is complete.

    Paul

  • How to count the number of pages on the spread

    How to count the number of pages on the spread

    #include "ILayoutControlData.h".

    #include "ILayoutUIUtils.h".

    #include "ISpread.h".

    InterfacePtr layoutData (Utils()-> QueryFrontLayoutData());

    If (layoutData)

    {

    UIDRef spreadRef is layoutData-> GetSpreadRef();.

    InterfacePtr activeSpread (spreadRef, UseDefaultIID ());

    Int32 count is activeSpread-> GetNumPages();.   Number of pages of active propagation.

    }

  • How to count the number or lines in the file

    Hi Experts,

    I'm file as source and Oracle as target. My folder that contains some data that will load the target.
    My requirement is that I want to count the number of lines that contains my folder. Please help me how to count the total number of lines in the file.


    THX,
    Sara.

    Hi Sahaveda,

    Now, I tried and it works.

    Sorry my mistake again.

    I created HR. ETL_FILE_LOG as below:

    CREATE THE TABLE HR. ETL_FILE_LOG (numero_fichier varchar2 (10))

    Below the code will run without error:

    import java.lang as lang

    import java.sql SQL

    import of java.lang.String

    Import os

    disadvantages is sql. DriverManager.getConnection ("<%=snpRef.getInfo("DEST_JAVA_URL")%>", "<%=snpRef.getInfo("DEST_USER_NAME")%>", "<%=snpRef.getInfo("DEST_PASS")%>")

    dblinks = cons.createStatement)

    File1 = Open ('c:\EMP.txt','r')

    Count = 0

    Line = file1. ReadLine()

    all online! ='' :

    Count += 1

    Line = file1. ReadLine()

    File1. Close()

    sqlQuery = "insert into HR. "The values of ETL_FILE_LOG (numero_fichier) (" + str (count) + ' ") '.

    rqQuery = dblinks.execute (sqlQuery)

    jerks. Close()

    Concerning

  • How to count the number of hit on the page, click

    Hello..
    can someone tell me...
    How to count the number of hit on the page, click

    Thanks in anticipation...

    Somethig like that?
    http://www.baigzeeshan.com/2011/12/Oracle-ADF-storing-temporary-values-in.html

  • How to count the number of nodes under each parent in any given xml

    How to count the number of nodes under each parent in any given xml. for example the xml below was
    books has 3 childern, library [1] has 4, [2] library has 6 and bookshop [3] has 2. is it possible to get the number of tags in a childnode duplicate IE library [1]
    Book1 Tagus repeated twice... vice versa. do we need to make plsql lie we can achieve through sql

    < book >
    < library >
    ABC < book1 > < / book1 >
    BCA < book2 > < / book2 >
    ACR < book1 > < / book1 >
    Lac < Book4 > < / Book4 >
    < / book >
    < library >
    ABC < book1 > < / book1 >
    BCA < book2 > < / book2 >
    ACR < book3 > < / book3 >
    ACR < book3 > < / book3 >
    tray of < bookn_1 > < / bookn_1 >
    adjusted cost base < bookn > < / bookn >
    < / book >
    < library >
    ABC < book1 > < / book1 >
    BCA < book2 > < / book2 >
    < / book >
    < / books >


    I tried this... query.

    Select
    XMLQUERY ('count($doc/Books/Bookstore[1]/descendant::*)' in the way of xmltype ("< books >
    < library >
    ABC < book1 > < / book1 >
    ACR < book1 > < / book1 >
    Lac < Book4 > < / Book4 >
    < / book >
    < library >
    ABC < book1 > < / book1 >
    BCA < book2 > < / book2 >
    < / book >
    (< / books > ')
    as 'doc' of happy return) .getNumberVal () as node_count
    of the double

    Select
    XMLQUERY ('count($doc/Books/descendant::*)' in the way of xmltype ("< books >
    < library >
    ABC < book1 > < / book1 >
    ACR < book1 > < / book1 >
    Lac < Book4 > < / Book4 >
    < / book >
    < library >
    ABC < book1 > < / book1 >
    BCA < book2 > < / book2 >
    < / book >
    (< / books > ')
    as 'doc' of happy return) .getNumberVal () as node_count
    of the double

    How can I get the counts for each parent in a single query

    Published by: user7955917 on August 24, 2012 07:26

    Generic function how you want the query to be.

    If the structure is known in advance, as in your example a 'books' and then a 'library' root element, it's as simple as:

    SQL> select x1.parent_id, x2.child_name, count(*)
      2  from tmp_xml t
      3     , xmltable(
      4         '/books/bookstore'
      5         passing t.object_value
      6         columns parent_id   for ordinality
      7               , child_list  xmltype path '*'
      8       ) x1
      9     , xmltable(
     10         '/*'
     11         passing x1.child_list
     12         columns child_name varchar2(30) path 'name()'
     13       ) x2
     14  group by x1.parent_id, x2.child_name
     15  order by x1.parent_id, x2.child_name
     16  ;
    
     PARENT_ID CHILD_NAME                       COUNT(*)
    ---------- ------------------------------ ----------
             1 book1                                   2
             1 book2                                   1
             1 book4                                   1
             2 bookn                                   1
             2 bookn_1                                 1
             2 book1                                   1
             2 book2                                   1
             2 book3                                   2
             3 book1                                   1
             3 book2                                   1
    
    10 rows selected
     
    

    If you want a generic solution that works without knowledge of the structure, you will need a recursive approach, and most importantly, you should know which nodes in distinct, I suppose that the leafs?

    Also, please help if you can provide the link of reference on the function name() years what are the other expression, that I can use after the path

    You can start reading the documentation: http://docs.oracle.com/cd/E11882_01/appdev.112/e23094/xdb_xquery.htm#CBAGCBGJ

    The clause PATH expects a XQuery expression however before 11.2, we can put only simple XPath expressions.

  • How to count the number of columns in an oracle table using sql

    How to count the number of columns in an oracle table using sql

    You must put the name of the table in capital letters

    As

    SELECT COUNT(1)
      FROM user_tab_columns
    WHERE table_name = 'EMP';
    
    or
    
    SELECT COUNT(1)
      FROM user_tab_columns
    WHERE table_name = UPPER('Emp');
    

    Concerning
    Arun

  • How to insert the current date in a hidden field?

    I have a form of update of personal information.  There is a field called 'dateupdated' that I would have on the form as a hiddent field that gets automatically the most recent date (now) in the table.

    No idea how I can configure the hiddden in the current date field?

    Thank you, Dennis

    Its good to know the TIMESTAMP data type.

    I do it in a different way.

    Add this code in the value of the hidden field date

Maybe you are looking for

  • HP DV6871US infrared remote not working do not on Windows 7 (32 bit)

    It comes to my laptop. It's the distance in question: I have Windows 7 Ultimate (32 bit) installed. I used Windows Update and that fixes almost all driver problems. Page for this laptop to official HP support said that there is not any drivers for th

  • Missing components of Vista after the virus attack

    Original title: Virus turned away from windows. Has managed to remove it, but now the system has missing parts. It took a while, but I finally got deleted. It looked like a Flash update and then took the whole computer. I have an older version of ERD

  • Cannot install drivers wifi Pavilion g6-1195sa

    HP Pavilion g6-1195sa Product no.: QC169EA£ ABU Due to problems of virus, I tried to perform a system restore, but could not get it started. So I used a DVD I had to do a reinstall of Windows 7 Home Premium (64-bit). However, I can't get the wireless

  • Can I use HP pavilion g7 - 2023cl Notebook PC overseas with 220 voltage

    Go abroad in England and France. The g7 - 2023cl notebook pavilion is able to work with a 220 voltage range. I don't want to damage my pc!

  • jqPlot Charting - WebView.evaluateJavaScript)

    I played arround with jqPlot (http://www.jqplot.com) to activate the graphics capabilities in my BB 10 app. So far, I've been able to generate most of the graph required except for the graphics containing tables of date/time data types. When I insert