request with the date of the Group's values

Hi all

I have an adate of table with 13 columns with a column named trandate
with the value as "2008-11-07 18:00:19.

Now I want to retrieve the values from the table as


SELECT count (*) from trandate which where ttype = '081' and T_FILE like 'mountain % ';

I want to count the records for all the months as


Jan-2009 - 120 (120 is the number of records satifying the above condition and belong to the period January 2009 (derived from trandate column)
Feb-2009 - 150 (150 is the number of records satifying the above condition and belong to the period February 2009 (derived from trandate column)


How can I rewrite the query


Thank you
Kai

Published by: KaiS on February 1st, 2011 04:23
select to_char(trandate,'mmm - yyyy') trandate,
          count(1)
from trandate
where where ttype = '081' and T_FILE like 'monT%'
group by to_char(trandate,'mmm - yyyy');

Tags: Database

Similar Questions

  • Detection of colliding with the grouped shapes

    Hello world.
    I'm having a problem with collision detection.
    I do an underwater game where the submarines are groups of shapes (two ellipses and two small rectangles).
    I use a circle (IARC) object for the missiles.


    It detects collisions when I do this:
    //////////////////////////////////////////////////
    If (circ.intersects (sub.getBoundsInLocal ()))
    {
    System.out.println ("you been touched");
    Returns true;
    }
    /////////////////////////////////////////////////



    Or it detects collision if I do:
    ////////////////////////////////////////////////
    If (sub.getChildren () .get (2) .intersects (circ.getBoundsInLocal ()))
    {
    System.out.println ("you been touched");
    Returns true;
    }
    ///////////////////////////////////////////////////////////////////////
    (the child in the 2 index is the main body of the Sub - ellipse shape)



    If I add an object not grouped as a simple rectangle shape and check the collisions on it then it detects very well. 'r' is the rectangle object.
    ////////////////////////////////////////////////////////////////////////
    If (circ.intersects (r.getBoundsInLocal ()))
    {
    System.out.println ("you hit sucker");
    Returns true;
    }
    ///////////////////////////////////////////////////////////////////////////



    Can we see why it will not work with the grouped shapes or a child of the Group? Or y at - it a simpler way that I'm missing?

    Thanks a lot :)

    For a group shape, use the boundsInParent property.

        circ.intersects(sub.getBoundsInParent())
    
  • Concatenation of data with the GROUP BY clause

    Hi again!

    Following my previous thread...
    Re: Need help with RANK() on data ZERO

    I tried to apply the GROUP BY clause instead of preforming my query with RANK() to manage records NULL... I have a scenario where I also need to concatenate data from several lines.

    CREATE TABLE T_EMP (NUMBER OF EMP_NO, NAME VARCHAR2 (20));
    INSERT INTO T_EMP VALUES (1001, 'MARK');
    INSERT INTO T_EMP VALUES (1002, 'DAVID');
    INSERT INTO T_EMP VALUES (1003, "SHAUN");
    INSERT INTO T_EMP VALUES (1004, "JILL");

    CREATE TABLE T_EMP_DEPT (NUMBER OF EMP_NO, DEPT_NO NUMBER);
    INSERT INTO T_EMP_DEPT VALUES (1001, 10);
    INSERT INTO T_EMP_DEPT VALUES (1001, 20);
    INSERT INTO T_EMP_DEPT VALUES (1002, 10);
    INSERT INTO T_EMP_DEPT VALUES (1002, 20);
    INSERT INTO T_EMP_DEPT VALUES (1002, 30);
    INSERT INTO T_EMP_DEPT VALUES (1003, 20);
    INSERT INTO T_EMP_DEPT VALUES (1003, 30);
    INSERT INTO T_EMP_DEPT VALUES (1004, 10);

    CREATE TABLE T_EMP_VISITS (NUMBER OF EMP_NO, DEPT_NO NUMBER, VISITED DATE);
    INSERT INTO T_EMP_VISITS VALUES (1001, 10, 1 JAN 2009');
    INSERT INTO T_EMP_VISITS VALUES (1002, 10, 1 JAN 2009');
    INSERT INTO T_EMP_VISITS VALUES (1002, 30, 11 APR 2009');
    INSERT INTO T_EMP_VISITS VALUES (1003, 20, 3 MAY 2009');
    INSERT INTO T_EMP_VISITS VALUES (1003, 30: 14 FEB 2009');
    COMMIT;

    I have a T_EMP master table that stores the name and number of the emp. Each emp is required to visit some departments. This mapping is stored in the T_EMP_DEPT table. An employee can visit one or more departments. T_EMP_VISITS table stores the dates where the employee visited the services required. I need to view the report which should show when an employee all completed visits, which is the maximum date when it finished to visit all departments. If he did not visit any of the report should display date max, otherwise NULL. I was able to do using GROUP BY such proposed by Salim, but how do I show a list separated by commas of the services required for an employee in the same query.

    SELECT
    EMP_NO,
    NAME,
    MAX (DEPT_NO) KEEP (DENSE_RANK LAST ORDER BY VISITED) MAX_DEPT_NO,.
    MAX (VISITED) KEEP (DENSE_RANK LAST ORDER PER VISIT) VISITS_COMP
    DE)
    SELECT
    T_EMP. EMP_NO,
    NAME,
    T_EMP_DEPT. DEPT_NO,
    VISITED
    OF T_EMP
    LEFT OUTER JOIN T_EMP_DEPT
    ON T_EMP. EMP_NO = T_EMP_DEPT. EMP_NO
    LEFT OUTER JOIN T_EMP_VISITS
    ON T_EMP_DEPT. EMP_NO = T_EMP_VISITS. EMP_NO
    AND T_EMP_DEPT. DEPT_NO = T_EMP_VISITS. DEPT_NO)
    GROUP EMP_NO, NAME;

    Output
    EMP_NO NAME MAX_DEPT_NO VISITS_COMP
    1001 MARK 20
    1002 DAVID 20
    1003 SHAUN 20 3 MAY 09
    JILL 1004

    Power required
    EMP_NO NAME REQ_DEPTS MAX_DEPT_NO VISITS_COMP
    1001 MARC 20 10.20
    1002 DAVID 10,20,30 20
    1003 SHAUN 20,30 20 3 MAY 09
    JILL 10 1004

    Can we do this in a single query?

    Hello

    user512647 wrote:
    ... Sanjay
    The query you provided that stragg() use seems to work but my requirement is not in the result set. I don't know how to use stragg with
    MAX (DEPT_NO) KEEP (DENSE_RANK LAST ORDER BY VISITED) MAX_DEPT_NO,.
    MAX (VISITED) KEEP (DENSE_RANK LAST ORDER PER VISIT) VISITS_COMP
    I need more, these two columns these gives me the date when they have completed all visits. If they missed any Department then the result must be NULL in the VISITS_COMP field.

    Just add them to the SELECT clause:

    SELECT    t_emp.emp_no,
           name,
           STRAGG (t_emp_dept.dept_no)     AS deptno,
           MAX (t_emp_dept.dept_no) KEEP (DENSE_RANK LAST ORDER BY visited)
                                      AS max_dept_no,
           MAX (visited)                      AS visits_comp
    FROM             t_emp
    LEFT OUTER JOIN      t_emp_dept     ON   t_emp.emp_no     = t_emp_dept.emp_no
    LEFT OUTER JOIN      t_emp_visits     ON   t_emp_dept.emp_no     = t_emp_visits.emp_no
                                 AND  t_emp_dept.dept_no = t_emp_visits.dept_no
    GROUP BY  t_emp.emp_no
    ,            name
    ;
    

    The column called visit_comp is simply the last visited, regardless of how the employee visited departments.
    If you want to have the NULL value if the employee has not yet visited all 3 departments:

    ...       CASE
              WHEN  COUNT (DISTINCT t_emp_dept.dept_no) = 3
              THEN  MAX (visited)
           END                    AS visits_comp
    

    The 'magic number' 3 is the total number of departments.
    If you want to understand the correct value of that at the time of the execution of the query, replace the code literal 3 hard with a scalar subquery.

    Note that 'KEEP MAX (x) (DENSE_RANK OVER LAST SERVICE BY x)' (where the exact same column is used as an argument and that the ORDER BY column) is just "MAX (x)".

  • Is this a bug with the grouping sets?

    Version is the database of Oracle 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production
    SQL> with data as
      2  (select rownum r, 'X' x, 1 n from dual connect by rownum <= 10)
      3  select x
      4       , sum(n) s
      5       , (select sum(1) from dual where dummy = x) t
      6  from data
      7  group by grouping sets (x, ())
      8  /
    
    X          S          T
    - ---------- ----------
    X         10          1
              10
    SQL>  
    Shouldn't the superaggregate row have a 1 in the T column?

    Here's your QUERY with the addition of the GROUPING() function:

    SQL> WITH data AS
      2  (
      3     SELECT rownum r
      4          , 'X'    x
      5          , 1      n
      6     FROM   dual
      7     CONNECT BY rownum <= 10
      8  )
      9  SELECT GROUPING(x)
     10       , x
     11       , sum(n) s
     12       , (SELECT sum(1) FROM dual WHERE dummy = x) t
     13  FROM   data
     14  GROUP BY GROUPING SETS (x, ())
     15  ;
    
    GROUPING(X) X          S          T
    ----------- - ---------- ----------
              0 X         10          1
              1           10
    

    In this case, the value of X is zero because it is a subtotal line. If you look at this statement execution plan:

    PLAN_TABLE_OUTPUT
    ------------------------------------------------------------------------------------------------------------------------------
    SQL_ID  gumphwvgumqc4, child number 0
    -------------------------------------
    WITH data AS (  SELECT rownum r       , 'X'    x       , 1      n  FROM
      dual  CONNECT BY rownum <= 10 ) SELECT /*+gather_plan_statistics*/ x
        , sum(n) s      , (SELECT sum(1) FROM dual WHERE dummy = x) t FROM
     data GROUP BY GROUPING SETS (x, ())
    
    Plan hash value: 1718326399
    
    -----------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                       | Name | Starts | E-Rows | A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Used-Mem |
    -----------------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                |      |      1 |        |      2 |00:00:00.01 |       0 |    |  |          |
    |   1 |  SORT AGGREGATE                 |      |      2 |      1 |      2 |00:00:00.01 |       4 |    |  |          |
    |*  2 |   TABLE ACCESS FULL             | DUAL |      2 |      1 |      1 |00:00:00.01 |       4 |    |  |          |
    |   3 |  SORT GROUP BY ROLLUP           |      |      1 |      1 |      2 |00:00:00.01 |       0 |  2048 |  2048 | 2048  (0)|
    |   4 |   VIEW                          |      |      1 |      1 |     10 |00:00:00.01 |       0 |    |  |          |
    |   5 |    COUNT                        |      |      1 |        |     10 |00:00:00.01 |       0 |    |  |          |
    |   6 |     CONNECT BY WITHOUT FILTERING|      |      1 |        |     10 |00:00:00.01 |       0 |    |  |          |
    |   7 |      FAST DUAL                  |      |      1 |      1 |      1 |00:00:00.01 |       0 |    |  |          |
    -----------------------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - filter("DUMMY"=:B1)
    

    The value of X is related to the subquery. If X is zero this returns no rows (I'm sure you already knew that :)). I would say it should although confusing behavior. You get the same results if you use CUBE or ROLLUP as well.

  • Need help in the optimization of the query with the Group and joins by clause

    I'm having the problem by running the following query... It takes a lot of time. To simplify, I added the two tables FILE_STATUS = stores the file load details and COMM table Board table job showing records treated successfully and which was communicated to the other system real. Records with status = T is trasnmitted to another system and traansactions with P is waiting.
    CREATE TABLE FILE_STATUS
    (FILE_ID VARCHAR2(14),
    FILE_NAME VARCHAR2(20),
    CARR_CD VARCHAR2(5),
    TOT_REC NUMBER,
    TOT_SUCC NUMBER);
    
    CREATE TABLE COMM
    (SRC_FILE_ID VARCHAR2(14),
    REC_ID NUMBER,
    STATUS CHAR(1));
    
    INSERT INTO FILE_STATUS VALUES ('12345678', 'CM_LIBM.TXT', 'LIBM', 5, 4);
    INSERT INTO FILE_STATUS VALUES ('12345679', 'CM_HIPNT.TXT', 'HIPNT', 4, 0);
    
    INSERT INTO COMM VALUES ('12345678', 1, 'T');
    INSERT INTO COMM VALUES ('12345678', 3, 'T');
    INSERT INTO COMM VALUES ('12345678', 4, 'P');
    INSERT INTO COMM VALUES ('12345678', 5, 'P');
    COMMIT;
    Here's the query I wrote to give me the details of the file that has been loaded into the system. He reads the table of State and the commission files to display the name of the file, total records loaded, total at the table of the commission and the number of records which has finally been passed successfully loaded (Status = T) with other systems.
    SELECT 
        FS.CARR_CD 
        ,FS.FILE_NAME 
        ,FS.FILE_ID
        ,FS.TOT_REC
        ,FS.TOT_SUCC
        ,NVL(C.TOT_TRANS, 0) TOT_TRANS
    FROM FILE_STATUS FS
    LEFT JOIN
    (
        SELECT SRC_FILE_ID, COUNT(*) TOT_TRANS
        FROM COMM
        WHERE STATUS = 'T'
        GROUP BY SRC_FILE_ID
    ) C ON C.SRC_FILE_ID = FS.FILE_ID
    WHERE FILE_ID = '12345678';
    In production, this request has several joins and takes a long time to deal with... the main culprit for me is the join on the COMM table to count the number of number of transactions sent. Please can you give me tips to optimize this query to get results faster? What I need to delete the Group and use the partition or something else. Help, please!

    Don't know if it will be faster based on the information provided, but analytical functions offer an alternative approach;

    select carr_cd, file_name, file_id, tot_rec, tot_succ, tot_trans
      from (select fs.carr_cd,
                   fs.file_name,
                   fs.file_id,
                   fs.tot_rec,
                   fs.tot_succ,
                   count(case
                            when c.status = 'T' then
                             1
                            else
                             null
                          end) over(partition by c.src_file_id) tot_trans,
                   row_number() over(partition by c.src_file_id order by null) rn
              from file_status fs
              left join comm c
                on c.src_file_id = fs.file_id
             where file_id = '12345678')
     where rn = 1;
    
    CARR_CD FILE_NAME            FILE_ID           TOT_REC   TOT_SUCC  TOT_TRANS
    ------- -------------------- -------------- ---------- ---------- ----------
    LIBM    CM_LIBM.TXT          12345678                5          4          2
    
  • Received an email "(null)" with the group mailing list

    I have updated to OS X 10.6.x for OS X 10.11.2 with Server (5.0), then turned on the messaging service.

    Then after some members of the Group received mail "(null)". I mean there is '(null)' text only in the body of the message and no subject of the mail.

    The sender of the email is also strange. If the email is '[email protected]', the sender of the email is "[email protected]".

    Do you know how can I solve the problem?

    I saw this same error several times with one of my clients.  I test this potential solution - verify access to Services for the Group and make sure that it has access to messaging enabled.

    Bryan Dulock

    ACN

    Houston, TX

  • Someone had problems with the Group Me app?

    After you download this app and sync my contacts, I have an unknown person in my list of contacts that the person is in my address book.  I do not know this person and I couldn't get a response from the Group Me support app, and their page url does not exist.  Support people sent me a generic email and told me how to remove a member, but I have been unable to solve the problem of the way that they describe. Now, I can't get rid of that person.  I am afraid that they have access to all my contact information now.

    https://help.groupme.com/HC/en-us/community/topics is the community for the App... it doesn't seem that there's a lot of traffic

    I would normally ask here, but the number of post on the homepage is VERY low

    It belongs to the family of 'Skype' products owned ultimately by Microsoft

  • A question about the analytical function used with the GROUP BY clause in SHORT

    Hi all

    I created the following table named myenterprise
    CITY       STOREID    MONTH_NAME TOTAL_SALES            
    ---------- ---------- ---------- ---------------------- 
    paris      id1        January    1000                   
    paris      id1        March      7000                   
    paris      id1        April      2000                   
    paris      id2        November   2000                   
    paris      id3        January    5000                   
    london     id4        Janaury    3000                   
    london     id4        August     6000                   
    london     id5        September  500                    
    london     id5        November   1000
    If I want to find which is the total sales by city? I'll run the following query
    SELECT city, SUM(total_sales) AS TOTAL_SALES_PER_CITY
    FROM myenterprise
    GROUP BY city
    ORDER BY city, TOTAL_SALES_PER_CITY;
    that works very well and produces the expected result, i.e.
    CITY       TOTAL_SALES_PER_CITY   
    ---------- ---------------------- 
    london     10500                  
    paris      17000            
    Now in one of my books SQL (Mastering Oracle SQL) I found another method by using the SUM, but this time as an analytic function. Here's what the method of the book suggests as an alternative to the problem:
    SELECT city, 
           SUM(SUM(total_sales)) OVER (PARTITION BY city) AS TOTAL_SALES_PER_CITY
    FROM myenterprise
    GROUP BY city
    ORDER BY city, TOTAL_SALES_PER_CITY;
    I know that the analytic functions are executed after the GROUP BY clause has been transformed completely and Unlike regular aggregate functions, they return their result for each line belonging to the partitions specified in the partition clause (if there is a defined partition clause).

    Now my problem is that I do not understand what we have to use two functions SUM? If we only use one only, i.e.
    SELECT city, 
           SUM(total_sales) OVER (PARTITION BY city) AS TOTAL_SALES_PER_CITY
    FROM myenterprise
    GROUP BY city
    ORDER BY city, TOTAL_SALES_PER_CITY;
    This generates the following error:
    Error starting at line 2 in command:
    SELECT city, 
           SUM(total_sales) OVER (PARTITION BY city) AS TOTAL_SALES_PER_CITY
    FROM myenterprise
    GROUP BY city
    ORDER BY city, TOTAL_SALES_PER_CITY
    Error at Command Line:2 Column:11
    Error report:
    SQL Error: ORA-00979: not a GROUP BY expression
    00979. 00000 -  "not a GROUP BY expression"
    *Cause:    
    *Action:
    The error is generated for the line 2 column 11 which is, for the expression SUM (total_sales), well it's true that total_sales does not appear in the GROUP BY clause, but this should not be a problem, it has been used in an analytical function, so it is evaluated after the GROUP BY clause.

    So here's my question:

    Why use SUM (SUM (total_sales)) instead of SUM (total_sales)?


    Thanks in advance!
    :)





    In case you are interested, that's my definition of the table:
    DROP TABLE myenterprise;
    CREATE TABLE myenterprise(
    city VARCHAR2(10), 
    storeid VARCHAR2(10),
    month_name VARCHAR2(10),
    total_sales NUMBER);
    
    INSERT INTO myenterprise(city, storeid, month_name, total_sales)
      VALUES ('paris', 'id1', 'January', 1000);
    INSERT INTO myenterprise(city, storeid, month_name, total_sales)
      VALUES ('paris', 'id1', 'March', 7000);
    INSERT INTO myenterprise(city, storeid, month_name, total_sales)
      VALUES ('paris', 'id1', 'April', 2000);
    INSERT INTO myenterprise(city, storeid, month_name, total_sales)
      VALUES ('paris', 'id2', 'November', 2000);
    INSERT INTO myenterprise(city, storeid, month_name, total_sales)
      VALUES ('paris', 'id3', 'January', 5000);
    INSERT INTO myenterprise(city, storeid, month_name, total_sales)
      VALUES ('london', 'id4', 'Janaury', 3000);
    INSERT INTO myenterprise(city, storeid, month_name, total_sales)
      VALUES ('london', 'id4', 'August', 6000);
    INSERT INTO myenterprise(city, storeid, month_name, total_sales)
      VALUES ('london', 'id5', 'September', 500);
    INSERT INTO myenterprise(city, storeid, month_name, total_sales)
      VALUES ('london', 'id5', 'November', 1000);
    Edited by: dariyoosh on April 9, 2009 04:51

    It is clear that thet Analytics is reduntant here...
    You can even use AVG or any analytic function...

    SQL> SELECT city,
      2         avg(SUM(total_sales)) OVER (PARTITION BY city) AS TOTAL_SALES_PER_CITY
      3  FROM myenterprise
      4  GROUP BY city
      5  ORDER BY city, TOTAL_SALES_PER_CITY;
    
    CITY       TOTAL_SALES_PER_CITY
    ---------- --------------------
    london                    10500
    paris                     17000
    
  • column values with the same key value addition

    Dear professionals,
    I created the table like this:
     create table acc_test (
    id      number,
    col1    varchar2(20),
    col2    number,
    col3    number);
    
    insert into acc_test (id,col1,col2,col3) values ('1','ttt','10','15');
    insert into acc_test (id,col1,col2,col3) values ('1','aba','5','0');
    insert into acc_test (id,col1,col2,col3) values ('2','abc','12','7');
    insert into acc_test (id,col1,col2,col3) values ('3','ddd','6','15');
    insert into acc_test (id,col1,col2,col3) values ('3','df','4','15');
    insert into acc_test (id,col1,col2,col3) values ('4','kl','10','15');
    How to write a query for this data set:
    ID                     COL1                 COL2             COL3 
    ---------------------- -------------------- ---------------------- -----
    1                      ttt                  15 (10+5)          15  (15+0) 
    2                      abc                  12                 7    
    3                      ddd                  10 (6+4)           30  (15+15)   
    4                      kl                   10                 15   
    THX in advance,
    Adnan

    You can use this query:

    SQL> SELECT id,col1,SUM(col2) OVER (PARTITION BY id) col2
      2                ,SUM(col3) OVER (PARTITION BY id) col3
      3  FROM acc_test ;
    
            ID COL1                       COL2       COL3
    ---------- -------------------- ---------- ----------
             1 ttt                          15         15
             1 aba                          15         15
             2 abc                          12          7
             3 ddd                          10         30
             3 df                           10         30
             4 kl                           10         15
    
    6 rows selected.
    

    However, if you notice that you can find that the two lines as

         ID COL1                       COL2       COL3
    ------- -------------------- ---------- ----------
          1 ttt                          15         15
          1 aba                          15         15
    

    are present in the result set. Now, he must explain that you want to remove, and why.

    If you say, it is not important, then with the data of your second posting, it's even easier!

    SQL> SELECT id,col1,SUM(col2)
      2                ,SUM(col3)
      3  FROM acc_test
      4  GROUP BY id,col1
      5  ORDER BY 1 ;
    
            ID COL1                  SUM(COL2)  SUM(COL3)
    ---------- -------------------- ---------- ----------
             1 ttt                          15         15
             2 abc                          12          7
             3 ddd                          10         30
             4 kl                           10         15
    

    Published by: Johan on November 24, 2010 16:48

  • Need help with the accumulation of value.

    Hello world

    My version of DB is

    BANNER

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

    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi

    PL/SQL Release 10.2.0.1.0 - Production

    CORE 10.2.0.1.0 Production

    AMT for Linux: Version 10.2.0.1.0 - Production

    NLSRTL Version 10.2.0.1.0 - Production

    Please take a look at the structure of the table, some examples of values, query, and result and help out me.

    create table ppdev_own.product

    (

    number of product_id,

    sold_date date null not activate.

    activate the sold_quantity number not null,

    constraint product_pk primary key (product_id, sold_date, sold_quantity) activation

    ) ;

    insert into product (product_id, sold_date, sold_quantity) values (1000, to_date('12-NOV-2014','DD-MON-YYYY'), 100);

    insert into product (product_id, sold_date, sold_quantity) values (1000, to_date('12-DEC-2014','DD-MON-YYYY'), 150);

    insert into product (product_id, sold_date, sold_quantity) values (1000, to_date('12-JAN-2015','DD-MON-YYYY'), 200);

    insert into product (product_id, sold_date, sold_quantity) values (2000, to_date('12-NOV-2014','DD-MON-YYYY'), 120);

    insert into product (product_id, sold_date, sold_quantity) values (2000, to_date('12-DEC-2014','DD-MON-YYYY'), 170);

    insert into product (product_id, sold_date, sold_quantity) values (2000, to_date('12-JAN-2015','DD-MON-YYYY'), 220);

    insert into product (product_id, sold_date, sold_quantity) values (2000, to_date('13-JAN-2015','DD-MON-YYYY'), 100);

    -Query

    with the temp as

    (select distinct p1.product_id,

    P1.sold_date,

    P1.sold_quantity,

    Count (*) on total_occurrence (p1.product_id partition).

    ROW_NUMBER() over (partition by product_id arrested by p1.product_id) rownumber

    the product p1

    order of p1.product_id,

    P1.sold_date

    )

    Select t.product_id,

    t.sold_date,

    t.sold_quantity,

    case

    When lag (t.sold_quantity) over (partition by t.product_id of t.product_id order) is null

    then t.sold_quantity

    When t.rownumber < t.total_occurrence

    then lag (t.sold_quantity) over (partition by order of t.product_id t.product_id) + t.sold_quantity

    When t.total_occurrence = t.rownumber

    then sum (t.sold_quantity) on (t.product_id score)

    end as sold_quantity_acc

    t temp;

    Result

    PRODUCT_IDSOLD_DATESOLD_QUANTITYSOLD_QUANTITY_ACC
    1000JANUARY 12, 2015200200
    100012 DECEMBER 2014150350
    1000NOVEMBER 12, 2014100450
    2000JANUARY 12, 2015220220
    200012 DECEMBER 2014170390
    2000JANUARY 13, 2015100270 -instead of 270, he must return to 490
    2000NOVEMBER 12, 2014120610

    Please see the comment in bold and help out me. How can I maintain the continuous accumulation of value that will keep calculation of the quantity sold. Please correct me if my approach is wrong.

    Kind regards

    BS2012.

    Select product_id,

    sold_date,

    sold_quantity,

    Sum (sold_quantity) on sold_quantity_acc (partition by product_id arrested by sold_date)

    product

    PRODUCT_ID SOLD_DATE SOLD_QUANTITY SOLD_QUANTITY_ACC
    1000 12/11/2014 100 100
    1000 12/12/2014 150 250
    1000 12/01/2015 200 450
    2000 12/11/2014 120 120
    2000 12/12/2014 170 290
    2000 12/01/2015 220 510
    2000 13/01/2015 100 610

    Concerning

    Etbin

  • Problem with the change in value of listbox event

    Hello

    I have a problem with the help of Listbox value change event. The code that I have attached is a simplified version of the largest program, but the problem is the same. One of the loops of Nonna is responsible for handlig occurring events ant the other is responsible for the execution of the program. In the project of oryginal I use a listbox control to determine which plots graphic display of a waveform is visible (first position of the listbox-> only plot first visible etc.). In the attached vi, I just show the current value of the listbox control. The problem is the event runs only once and then the program crashes. I want to be able to change the value of the listbox work both at idle and in State of a program, but when I put the structure of the event in both States, he does not. I'd be very grateful if someone smarter than me could tell me where I made my mistake. I want my program to be able to manage the keys and listbox events in States (slow down and knit) program.

    You have two structures of event in two cases different from the structure of the case, and both are tuned to listbox events has changed. Because only once can be triggered at any time, the VI crashes (lock events the front panel (default) until the event can complement).

    You must use a unique event structure managing all events.

    The overall program architecture looks like inside-out for me.

    For the buttosn, you must use action lock (switch not release!) and use the value changed events.

  • With the help of value in an input text for the calculation in a Variable area

    I have a project where I ask the user to fill out their name in a box entry and two-digit age in another area of text entry.  Later in the project, I want to ask them to think when they were 6 years and how they would describe themselves right there.  (the project is about self-awareness).  To make it as pleasant as possible, I thought it would be nice to say. "(Name variable), think to (years since 6) years, when you were about 6 years old'."  I'm unable to get the variable 'Since 6 years' work and I would like to know if it's possible.

    • I set up the variable text box as "v_age".
    • I've implemented a variable like "v_age6" with the value "6".
    • I implemented the variable result as "v_result_age6".
    • I have set up a standard action with a mathematical expression which reads "v_result_age6 = v_age - v_age6.

    The variable output does not appear on the scene in overview of project mode, and I think it's because there is only a single variable with a value assigned in the equation.  The variable "v_age" doesn't have an assigned value because it is a text entry area.

    Is it possible to use a value typed in a user as a variable to do math with?

    Thank you.

    Welcome to the forum,

    Each TEB has an associated variable, its generic name is the same as the BER. But you better match your variable with the most significant name to the ETB. Take a look at this old real blog post, always to news (though perhaps the screenshots are little bit outdated):

    http://blog.lilybiri.com/timesaving-Tip-Create-associated-variable-for

    BTW: you have no need to create an additional variable to number 6. This action would have done as well:

    Expression v_resultage6 = v_age - 6

    How you trigger the action, by what event?

    http://blog.lilybiri.com/events-and-advanced-actions

    Lilybiri

  • With the button submit values going to the Web page

    I have a form with 4 settings I want to go to a pop chart.

    I want to program a button that will present to the user selected values while they met in session state and then be available to pass these variables to the popchart.

    I created a button called run the report and set it to redirect to URLjavascript:doSubmit('SUBMIT'); popupURL ('http://tacweb-dev.co.ihc.com/ROMS/rpt_volumes.jsp?deptNum= & P12_APP_DEPT_ID & startDate = & P12_START_DATE. & endDate = & P12_END_DATE. & ther = & P12_THERAPIST_PRVDR_ID.');

    However, this does not work as the values entered into the fields do not have and they are in the form of values in session state.
    The function of the URL works.
    All I have to do is find a way to set the values entered by users in the session state.

    Hello

    You must call the function I posted something like this

    SetAppItem('P12_APP_DEPT_ID',$v('P12_APP_DEPT_ID'));
    

    That the value point P12_APP_DEPT_ID one that exists in the current html document

    But you need set the session state for your objects to use the poppies?
    It could work like this in the url target button

    javascript:popupURL('http://tacweb-dev.co.ihc.com/ROMS/rpt_volumes.jsp?deptNum='+$v('P12_APP_DEPT_ID')+'&startDate='+$v('P12_START_DATE')+'&endDate='+$v('P12_END_DATE')+'&ther='+$v('P12_THERAPIST_PRVDR_ID'));
    

    BR, Jari

  • How to make the SOAP request with the complex data types?

    Hi all

    I want to apply soap like that, how I can do this,


            string
            string


            dateTime
            dateTime

    string

    Thanks in advance.

    Any help?

  • Removal of special request with the tabs in the header header and using an Aero regular

    (If it help/questions, I usually use FF privately.) Normal mode does the same thing. I use Windows 7).

    Firefox does not use the standard Aero request header (I really don't know what else to call it). In FF, the header contains all tabs. This implies that it is specifically written code and does not use the standard Aero. Much even if I like it, ALL the time my driver nvlddmkm.sys crashes (and it crashes a LOT), there are the header, firefox, mangles it so that I can minimize is more, restoration, etc., and using the tabs can be sometimes difficult. Now before you say "This isn't for lack of FF", it's because none of my other applications that use the standard Aero interface, have these symptoms after a crash.

    Work is about to create a new FF window and manually drag-n-drop all my tabs on that and the problem is solved. But, in the light of my video driver usually block two or three times a session and since I usually twenty or more tabs in a session, this task can get boring. And since all I acquire using this FF header non-standard application is a little real estate on a 1080 screen, I do not see what is worth.

    So, what I want to do is off this "special FF header" and use the regular Aero it for Firefox. Is this possible? If so, how?

    And before you say, "Hang on, now, let's bury the lead, are we not? WTF is the problem with your video driver? Replace it! Fix your GPU! etc... "The drivers are all up to date, the GPU is almost brand new, I think my mobo is drunk and I have no money to replace the whole machine, still less the desire to start installing aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaall my applications. And finally, nobody, but nobody can tell me to what the problem with my PC. He's just drunk. We'll just work around this problem and try to solve the FF.

    Thanks for your help. Sorry it's so long, but I want to give as much information.

    I'm not sure I understand the nature of the accident: box 'title bar' of the window Firefox is corrupt, but Firefox continues to operate?

    To make the Firefox title bar look more like other applications, you can restore the current tab page title to this area at the top of the page, that will push the legs down. There is a button for this on the bottom left side of the Panel customize.

    Customize controls, buttons, and Firefox toolbars

    Make things easier or just extend the area of damage?

Maybe you are looking for

  • Upscaling 480 p to 1080 p - an impossible task?

    I have pictures of 720 x 480 I'm upscale up to 1920 x 1080. This is obviously a huge leap, perahps too huge to be feasible.  Yes, 480 p to 720 p can be OK but p 1980, probably not. Do you know the guys from anything that could do this for me? I tried

  • Pavilion Slimline 400: Installation problem

    I tried in vain to install my old Bejeweled game on my brand new HP Pavilion Slimline 400 office.  No matter how many times I clicked on the Install of the game on my screen button, nothing happened.  Oddly, I had no problem installing the same game

  • writing data to the worksheet

    Hi all I am trying to extract frequencies to help extract information from your multiple. However, I am facing problem record the frequency, amplitude, and phase in the file. Give me an error (it can't be wired together as their data types (digital,

  • Where can I download MDT 2008?

    Our installation of MDT 2008 is very personal and is not compatible with newer versions (and bosses do not want to spend the time and money it would take to make it compatible). I can't seem to find the x 86 or x 64 downloads for MDT 2008 and I need

  • Solitaire, hearts and other small game not available in Windows 7 Pro :-(

    Are small games like Solitaire, hearts and Minesweeper from mines etc that are available in Windows 7 Home Premium also available to be downloaded from somewhere? I miss my Solitataire and Spider Solitaire. I just go from XP to Windows 7 Professional