Count the record satisfied daily, weekly conditions

Hi,
I have a table which with the data being populated hourly (as below - with Date, Name, Value1, Value2 fields).
I would need to query to get:
1. Daily: Count the number of record which have Value1 <10 or Value2 >4 and occurs at least 3 times per day.
2. Weekly: Count the number of record which satisfied the condition in "Daily" and happens 7 days consecutively for the past week.
Thank you very much.
Alex
Table ABC               
Date     Name Value1     Value2
12/04/2010:01:00     TEST1     10     5
12/04/2010:02:00     TEST1     10     4
12/04/2010:03:00     TEST1     9     4
12/04/2010:04:00     TEST1     9     4
12/04/2010:05:00     TEST1     10     4
18/04/2010:01:00     TEST1     10     4
18/04/2010:02:00     TEST1     9     4
18/04/2010:03:00     TEST1     9     3
18/04/2010:04:00     TEST1     9     3
Edited by: user8606416 on 16-Apr-2010 02:39

We often help students ... but we insist that students help themselves too.
The first thing you can do is read the FAQ and learn how to format listings with tags so we can read them.
The second is that they try not just ask for a solution far more sophisticated than they could write themselves. I don't see evidence that you have tried to solve this yourself.
BTW: DATE and NAME are reserved words in Oracle and should never be used to name anything.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • To count the records in the database table...

    I want to count the number of records in the database table (infotypes PA0000)
    is it possible to count ?
    Any function module is there?
    Thanks in advance..

    Hi dhavamani ponnusamy,
    SELECT COUNT(*) FROM <DB TABLE NAME> WHERE <CONDITION>.
    or
    SY-DBCNT Will have total no of records satisfying the given criteria in where clause.
    See below sample..
    Data: itab like mara occurs 0 with header line.
    Select * from mara into table mara.
    write:/ sy-dbcnt.
    Hope it will solve your problem...
    Reward points if useful..
    Thanks & Regards
    ilesh 24x7

  • Count the Records in  an internal table without a loop.

    How do i count the number of records in an internal table without using the loop  statement.
    The Describe statement give the total no. of records in the internal table.But i want the count of the key fields in the internal table
    For eg
    Row Field
    1       A
    2       A
    3       A
    4       B
    5       B
    6       C
    Count of A = 3
    Count of B = 2
    Count of C = 1

    Dilip,
      I think isn't posible. Only 3 ideas:
    1ª, make other table "table2", similar to your actual table.
         table2[] = yourtable[].
         delete table2 where key <> 'A'.
         describe table table2 lines contA.
        But depending the amount of data, you may have problems in performance or memory consumption...
    2ª, make other table, only with the keys fields and a count field,
        data begin table2
           key_field1,
           cont type i.
        end data.
       when you append lines to yourdata, make a collect to this table:
        table2-keys = yourtable-keys.
        table2-cont = 1.
       collect table2.
       But only works if you can modify the program where data is appended, and you may be carefull when data is deleted :-(...
    3ª if your data if filled in a select, you may fill the table2 of point 2ª, making a similar select but:
       select keyfields count( * ) into table table2
      from ...
      where (the same you have to fill your original table...)
       group by keys.
    But you have the same problem is data is deleted later...
    I hope that any of the three is useful for you...
    Edited by: Diego Alvarez on Jan 5, 2010 5:09 PM

  • Count the records

    i have two tables like master and child having below records.Please find the records.
    Master table
    CODE STATUS
    ABC U
    ABC S
    Histrory Table
    CODE status
    ABC S
    I WANT THE RESULT
    STATUS COUNT
    U 1
    S 2
    i am using below query it is not working,It shows only for status(S) count 3 not for Status U.How shall we count this reocrd.,
    SELECT x+y as total from
    select count(1) x,staus from master
    where code like 'AB%' group by status
    select count(1) y,status from history
    where code like 'AB%' GROUP BY STATUS)

    Hello
    You need to union all the two tables together:
    tylerd@DEV2> CREATE TABLE dt_test_code_table
      2  (   col1    VARCHAR2(3),
      3      col2    VARCHAR2(1)
      4  )
      5  /
    Table created.
    Elapsed: 00:00:00.36
    tylerd@DEV2> CREATE TABLE dt_test_code_table_hist
      2  (   col1    VARCHAR2(3),
      3      col2    VARCHAR2(1)
      4  )
      5  /
    Table created.
    Elapsed: 00:00:00.04
    tylerd@DEV2>
    tylerd@DEV2> INSERT INTO dt_test_code_table VALUES('ABC','U')
      2  /
    1 row created.
    Elapsed: 00:00:00.01
    tylerd@DEV2> INSERT INTO dt_test_code_table VALUES('ABC','S')
      2  /
    1 row created.
    Elapsed: 00:00:00.00
    tylerd@DEV2> INSERT INTO dt_test_code_table_hist VALUES('ABC','U')
      2  /
    1 row created.
    Elapsed: 00:00:00.00
    tylerd@DEV2>
    tylerd@DEV2> SELECT
      2      COUNT(*),
      3      col2
      4  FROM
      5      (   SELECT
      6              col2
      7          FROM
      8              dt_test_code_table
      9          UNION ALL
    10          SELECT
    11              col2
    12          FROM
    13              dt_test_code_table_hist
    14      )
    15  GROUP BY
    16      col2
    17  /
      COUNT(*) C
             2 U
             1 S
    2 rows selected.
    Elapsed: 00:00:00.03HTH
    David
    Message was edited by:
    David Tyler
    Eric beat me too it! :-)

  • A column that counts the records......need some help

    say i have a table with values {a, b, c, d, f};
    i want a column that counts the rows of these records with out putting the value manually.
    COL1 COL2
    0 a
    1 b
    2 c
    3 d
    4 f
    I have created a data block (wizard) for inserting the values into the table. But i want it to insert the values in COL1 automatically. Seems easy but i dont seem to be able to figure this out...

    with tab1 as
    (select 'a' col2 from dual
    union all
    select 'b' col2 from dual
    union all
    select 'c' col2 from dual
    union all
    select 'd' col2 from dual
    union all
    select 'f' col2 from dual
    -- End of test data
    select rownum - 1 col1, col2 from
    (select col2 from tab1 order by col2)
    COL1 COL2
    0 a
    1 b
    2 c
    3 d
    4 f Regards
    Dmytro

  • ALV Count the records in group

    I have a report which list the billing documents which sort and group by sales office. The layout is something like this
    Sales Office      Billing Document    Amount
    A                      0001                     1000
    A                      0002                     1000
    Doc. count = 2
    B                      0003                     1500 
    Doc. count = 1
    I know that I can add a column with the value 1 in each cell and sum them up.
    Is that any other alternatives?

    Hi,
    Where do you want to show this count. Do you want to show it as the column in output or in the header of the ALV. You can just see the entries in the output table and print that count.
    Reward points if useful.
    Regards,
    Atish

  • How to count the records?

    Hi,
    My data in the report is like below:
    INVOICE# DATE QTY
    ==============================
    111 07/03/03 1
    RT1 07/05/03 1
    222 07/08/03 2
    333 07/09/03 2
    RT2 07/10/03 1
    Is there any way that I can sum the QTY OF all the 'RT' invoice#?
    Thanks,
    Jun

    Hi
    Just put a Reports lavl summary column that sums the QTY column. You can have the summary column at the page and group level also.
    Thanks
    Rohit

  • Getting the count of records in a cursor

    Hi,
    How can I get the count of records satisfying a conditin in a cursor.
    This is the code that I have written. Please tell me where I am going wrong.
    declare
    cursor c is
    select * from Details where Name like 'M%';
    rec number;
    r c%rowtype;
    begin
    for r in c
    loop
    rec:=rec+1;
    end loop;
    dbms_output.put_line(rec);
    end;
    Thanks in advance

    Hi,
    You have to initialize the rec variable.
    declare
    cursor c is
    select * from Details where Name like 'M%';
    rec number :=0;
    r c%rowtype;
    begin
    for r in c
    loop
    rec:=rec+1;
    end loop;
    dbms_output.put_line(rec);
    end;
    You can also use the %ROWCOUNT attribute.
    Regards

  • How to caculate the records count for a measurement with a filter?

    I have a fact table which add relationship to a datetime dimension. I create a measurement based on the fact table, like [MeasureA]. I want to calculate the record counts of [measureA] of today, how to write the mdx query? Thanks!

    Hi Lavandula,
    According to your description, you want to calculate the numbers of the record of a measure for a specific day, right? In this case, you can use
    Count function which returns the number of cells in a set to achieve you requirement. Here is a sample query on Adventure Works for your reference.
    WITH
    MEMBER [Measures].[SetCount] AS
    COUNT([Product].[Product].[Product].Members)
    SELECT
    {[Measures].[SetCount]} ON COLUMNS
    FROM
    [Adventure Works]
    Besides, if you want to count the cell numbers with a condition, you can use
    Filter funtion inside the Count function.
    WITH MEMBER [Measures].[High Volume Products Count] AS
    Count(Filter([Product].[Product].[Product], [Measures].[Internet Order Quantity] > 5))
    SELECT [Customer].[Customer Geography].[Country] ON 0
    , [Date].[Calendar].[Date].MEMBERS ON 1
    FROM [Adventure Works]
    WHERE [Measures].[High Volume Products Count]
    Regards,
    Charlie Liao
    TechNet Community Support

  • How to return the record count of a query to a number variable

    How would I get the record count from a query without using a cursor to step through the query and count the records individually?
    query: select * from table1 where column1 = column2
    How would I get the record count of the query above?
    thanks,
    michelle

    I figured it out
    select count(*) into theCount
    from ( select * from table1 where column1=column2 );
    thanks,
    michelle

  • Need a relative sequence (count of record) in an input file in ESB input fi

    I am using ESB to pick up text files and pass them to a stored procedure. I have multiple variable length records in the file. I pass each record to the
    output file adapter, along with the input filename. I would also like to get a relative record number for each record within the file. I use an xsd file
    to convert the input to XML. The entire file is at the root level, each record is an element. Is there a way to get a relative count of each element?
    Here is the xsd file:
    <?xml version="1.0" encoding="UTF-8" ?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
    targetNamespace="http://TargetNamespace.com/Filein"
    xmlns:tns="http://TargetNamespace.com/Filein"
    elementFormDefault="qualified"
    attributeFormDefault="unqualified" nxsd:encoding="ASCII" nxsd:stream="chars" nxsd:version="NXSD">
    <xsd:element name="Root-Element">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="C1" minOccurs="1" maxOccurs="unbounded">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="C1" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="${eol}" nxsd:quotedBy="&quot;">
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    <!--NXSDWIZ:J:\\UPLD5383.INM:-->
    <!--USE-HEADER:false:-->
    I need to map the relative record number to a field in the output.
    Is there a function similar to the get filename that would return this value to me?
    <xsl:value-of select='ehdr:getRequestHeader("/fhdr:InboundFileHeaderType/fhdr:fileName","fhdr=http://xmlns.oracle.com/pcbpel/adapter/file/;")'/>
    I use this in the xsl file to get the file name .

    does each record start with a new line? if it does a
    simple wc -l can help you. If not, you can pre
    process this XML file by first removing all the new
    line characters using sed and then adding new line
    characters after the end tag of the xml using sed and
    finally doing a wc -l . this would be a simple shell
    script. Not sure if you want to use Unix shell
    scripting to achieve this.The sheer nature of XML means that it does not conform to any visual formatting. i.e. An xml file containing...
    <employee><empno>3</empno></employee>
    is identical in XML terms to...
    <employee>
    <empno>3</empno>
    </employee>
    which is also identical in XML terms to...
    <employee>
    <empno>
    3
    </empno>
    </employee>
    which is also identical in XML terms to...
    <employee><empno>
    3
    </empno></employee>
    etc.
    You cannot rely on the number of CR's or CR/LF's in the file to count the records. Proper XML processing should be used for such a task.

  • How can I get a count of records in a DB?

    If I want to get a count of the number of records in a table how do I do it?

    Generally, it's good practice to close the connection once you're done with it unless you have a reason to keep going back to it, in which case it probably becomes a performance issue. If you need to keep accessing the same connection repeatedly while your form is running (in Acrobat), I think you would be best to leave it open after initialization.<br /><br />You might consider placing the code which counts the records into a function inside a Script Object. This way, you can just call the Script Object method and retrieve the record count whenever you need it.<br /><br />Make sure you define the <b>oDB</b> variable outside the function but inside the Script Object:<br /><pre>var oDB = null;<br /><br />function GetRecordCount()<br />{<br />  if (oDB == null)<br />  {<br />    var sDataConnectionName = "<value>"; // example - var sDataConnectionName = "MyDataConnection"; <br /><br />    // Search for sourceSet node which matchs the DataConnection name <br />    var nIndex = 0; <br />    while(xfa.sourceSet.nodes.item(nIndex).name != sDataConnectionName) <br />    { <br />      nIndex++; <br />    } <br /><br />    var oDB = xfa.sourceSet.nodes.item(nIndex); <br />    oDB.open();<br />  }<br /><br />  oDB.first(); <br /><br />  // Search node with the class name "command" <br />  var nDBIndex = 0; <br />  while(oDB.nodes.item(nDBIndex).className != "command") <br />  { <br />    nDBIndex++; <br />  } <br /><br />  // Backup the original settings before assigning BOF and EOF to stay <br />  var sBOFBackup = oDB.nodes.item(nDBIndex).query.recordSet.getAttribute("bofAction"); <br />  var sEOFBackup = oDB.nodes.item(nDBIndex).query.recordSet.getAttribute("eofAction"); <br /><br />  oDB.nodes.item(nDBIndex).query.recordSet.setAttribute("stayBOF", "bofAction"); <br />  oDB.nodes.item(nDBIndex).query.recordSet.setAttribute("stayEOF", "eofAction"); <br /><br />  var itemCount = 0; <br /><br />  while(!oDB.isEOF()) <br />  { <br />    itemCount++; <br />    oDB.next(); <br />  } <br /><br />  // Restore the original settings <br />  oDB.nodes.item(nDBIndex).query.recordSet.setAttribute(sBOFBackup, "bofAction"); <br />  oDB.nodes.item(nDBIndex).query.recordSet.setAttribute(sEOFBackup, "eofAction"); <br /><br />  return itemCount;<br />}</pre><br />You can create a script object by right-clicking on the top-level form node ("form1" by default). Say you name your script object "Utils", you can then call the function inside of it from any event script like this:<br /><pre>this.rawValue = Utils.GetRecordCount();</pre><br />Stefan<br />Adobe Systems

  • SQL to count the number of days between two dates

    Does any one have or know how to count the number of days/weeks between 2 dates.
    I have thought about using MONTHS_BETWEEN, but do not know how to make it accurate down to one day?
    Any suggestions would be appreciated.

    here are the different queries I came up with to do this, you may want to check it for perticular cases involving Sun and Sat as start and end dates.
    select to_number(to_char(to_date('21-JUL-00','dd-mon-yy'), 'ww'))
    - to_number(to_char(to_date('10-JUL-00','dd-mon-yy'), 'ww')) from dual;
    select (Next_Day(to_date('21-JUL-00','dd-mon-yy')-1, 'Sunday')
    - Next_Day(to_date('10-JUL-00','dd-mon-yy')-1, 'Sunday'))/7 from dual;
    select (Next_Day(to_date('21-JUL-00','dd-mon-yy')-6, 'Sunday')
    - Next_Day(to_date('10-JUL-00','dd-mon-yy')-6, 'Sunday'))/7 from dual;
    null

  • How can I count the number of values in one column which answer to a condition in another column?

    I'm using Numbers 3.2 and would like to count the names in a column which satisfy a condition in a different column. There are 3 "streams" through which these names have come to me, and I would like to easily identify how many have come from each stream. Any help?

    Hi DirtyDawg,
    COUNTIF is your friend here.
    If your source is in column C and your streams are 1, 2 and 3:
    =COUNTIF(C,"=stream1")
    =COUNTIF(C,"=stream2")
    =COUNTIF(C,"=stream3")
    These need to be in a footer or header row or in a different column than C.
    hope this helps,
    quinn

  • How to get the count of the records

    Hi all,
    how can we get the record count after the read statement.Means if we write a read statement based on a condition,then how can we know that how many records get effected for this read statement

    You can use loop statement to read the records and write in some internal table and after the end of the loop, you can use describe command to find the number of records.
    For eg. DESCRIBE TABLE tablename LINES lines.
    Here the "Lines" field will give the total number of records present in the table "tablename"

Maybe you are looking for