How to calculate counts from different dates into 1 date

Hi,
I have a scenario below
ID
Type
Country
Date
123AP1
P
US
1/1/2009
123A1
A
WO
4/4/2010
123A2
A
US
6/6/2011
123A3
A
US
8/8/2011
So, the logic I need to display is -
If, Type = P AND Country=US then count 1 where ID has 123AP1
else If Type = A AND Country=US then count 1 more where ID has 123AP1 on date 1/1/2009 (i.e. on Type P date)
So, result should show
ID
Type
Country
Date
Count
123AP1
P
US
1/1/2009
3
123A1
A
WO
4/4/2010
0
123A2
A
US
6/6/2011
123A3
A
US
8/8/2011

Please simplify the question while asking to make it easy to understand.. this question is very confusing to understand..
For your purpose you should be able to get the result using calculation context based count on a  conditional variable with all your logic
Create a variable like below
var =if  [Type] = 'P' [ID] = '123AP1' and [Country] = 'US' then 1 else if Type] = 'A' [ID] = '123A1' and [Country] <> 'US'  thenn 1
And then create a formula on this variable like below
Count = sum([Var]) forall [Date]

Similar Messages

  • How to insert values from different region into one table

    Hi everyone
    I have created a page which contains 4 html regions like region1,region 2 ...region 4
    in region 1 i created 2 text items like (emp_name,emp_id).
    in region 2 i created 2 date fields (start_date,end_date).
    In region3 i created a tabular form which contains(job , hire_date).
    in region 4 i created a textfield (%of Hike)
    So i want to create a button(submit) .when i press the button it will insert all the informations provided by the user in different regions will be inserted to a table called employee_information.
    Can i do this?
    If it is possible please tell me how to do this
    if not then tell me any alternative solution.
    Thanks,
    Regards,
    Sabyasachi

    Sabyasachi wrote:
    Hi fac586
    Can you please tell me step by step how to do it or can you please make an example in apex.oracle.com and give me the credentials so that i can know clarify my doubts.1. Create a Form using a Wizard. This will create the items and processes necessary to retrieve data from, and perform DML on, the table. The items will be contained in a single default region.
    2. Create custom HTML regions on page.
    3. Move items and buttons from the default region created by the Form Wizard by changing the Region value in the "Displayed" section of the item attributes page, or Page Items page; or reassign items to regions using the Reassign Region Items page.

  • How to do a SELECT from different tables into an internal table?

    How to do a SELECT from different tables into an internal table?
    I want to select data from MARA, MARC and ZPERSON and populate my ITAB_FINAL
    REPORT  zinternal_table.
    TABLES:
      mara,
      marc,
      zperson.
    TYPES:
    BEGIN OF str_table1,
      v_name LIKE zperson-zname,
      v_matnr LIKE marc-matnr,
      v_emarc LIKE marc-emarc,
      v_werks_d LIKE marc-werks_d,
      v_dstat LIKE marc-dstat,
      END OF str_table,
      i_table1 TYPE STANDARD TABLE OF str_table1.
    DATA:
    BEGIN OF str_table2,
    v_mandt LIKE mara-mandt,
    v_ernam LIKE mara-ernam,
      v_laeda LIKE mara-laeda,
    END OF str_table2,
    itab_final LIKE STANDARD TABLE OF str_table2.

    first find the link between mara , marc and zperson , if u have link to 3 tables then u can jus write a join and populate the table u want ( thats final table with all the fields).
    u defenitely have alink between mara and marc so join them and retrieve all data into one internal table.
    then for all the entries in that internal table retrieve data from zperson into another internal table.
    then loop at one internal table
    read another internal table where key equals in both the tables.
    finally assign fileds if sy-subrc = 0.
    gs_finaltable-matnr = gs_table-matnr
    etc...
    and finally append gs_finaltable to gt_finaltable.
    there u go ur final table has all the data u want.
    regards
    Edited by: BrightSide on Apr 2, 2009 3:49 PM

  • How to join  fields from different internal tables and display into one int

    hai i have one doubt...
    how to join  fields from different internal tables and display into one internal table..
    if anybody know the ans for this qus tell me......

    hii
    you can read data as per condition and then can join in one internal table using READ and APPEND statement..refer to following code.
    SELECT bwkey                         " Valuation Area
             bukrs                         " Company Code
        FROM t001k
        INTO TABLE i_t001k
       WHERE bukrs IN s_bukrs.
      IF sy-subrc EQ 0.
        SELECT bwkey                       " Valuation Area
               werks                       " Plant
          FROM t001w
          INTO TABLE i_t001w
           FOR ALL ENTRIES IN i_t001k
         WHERE bwkey = i_t001k-bwkey
           AND werks IN s_werks.
        IF sy-subrc EQ 0.
          LOOP AT i_output INTO wa_output.
            READ TABLE i_t001w INTO wa_t001w WITH KEY werks = wa_output-werks.
            READ TABLE i_t001k INTO wa_t001k WITH KEY bwkey = wa_t001w-bwkey.
            wa_output-bukrs = wa_t001k-bukrs.
            MODIFY i_output FROM wa_output.
            CLEAR wa_output.
          ENDLOOP.                         " LOOP AT i_output
        ENDIF.                             " IF sy-subrc EQ 0
    regards
    twinkal

  • How to calculate the hour difference between two dates?

    hi all,
    how to calculate the hour difference between two dates?
    eg i trying this...
    ((TO_DATE(TO_CHAR(GRNi.reference_date_4,'hh24:mi'),'hh24:mi') -
    TO_DATE(TO_CHAR(NVL(GRNi.reference_date_3,SYSDATE),'hh24:mi'),'hh24:mi'))*24)*60 Act_Hr
    Reg.
    AAK

    Hi
    To break the diff between 2 dates into days, hours, minutes, sec -- you can use the following:
    select to_char( created, 'dd-mon-yyyy hh24:mi:ss' ),
    trunc( sysdate-created ) "Dy",
    trunc( mod( (sysdate-created)*24, 24 ) ) "Hr",
    trunc( mod( (sysdate-created)*24*60, 60 ) ) "Mi",
    trunc( mod( (sysdate-created)*24*60*60, 60 ) ) "Sec",
    to_char( sysdate, 'dd-mon-yyyy hh24:mi:ss' ),
    sysdate-created "Tdy",
    (sysdate-created)*24 "Thr",
    (sysdate-created)*24*60 "Tmi",
    (sysdate-created)*24*60*60 "Tsec"
    from all_users
    where rownum < 50
    HTH
    RangaReddy

  • In Mail 7.3 on my Retina MacBook Pro on OS 10.9.4, how can I type from the keyboard into a mail message using the Apple Symbols font?

    In Mail 7.3 on my Retina MacBook Pro on OS 10.9.4, how can I type from the keyboard into a mail message using the Apple Symbols font?
    When I select the Apple Symbols font from the list accessed from under Format/"Show fonts"/collection-all fonts/Apple Symbol, and then continue typing, I get normal letters, if in a slightly different font.
    How can I type using the Apple Symbol font?  I want to use that font to include keyboard and cursor selections of actual screen symbols to help write easily understood explicit computer lesson emails to my 92 year-old mom from a few hundred miles away.
    Steve

    In Mail 7.3 on my Retina MacBook Pro on OS 10.9.4, how can I type from the keyboard into a mail message using the Apple Symbols font?
    When I select the Apple Symbols font from the list accessed from under Format/"Show fonts"/collection-all fonts/Apple Symbol, and then continue typing, I get normal letters, if in a slightly different font.
    How can I type using the Apple Symbol font?  I want to use that font to include keyboard and cursor selections of actual screen symbols to help write easily understood explicit computer lesson emails to my 92 year-old mom from a few hundred miles away.
    Steve

  • How to compare result from sql query with data writen in html input tag?

    how to compare result
    from sql query with data
    writen in html input tag?
    I need to compare
    user and password in html form
    with all user and password in database
    how to do this?
    or put the resulr from sql query
    in array
    please help me?

    Hi dejani
    first get the user name and password enter by the user
    using
    String sUsername=request.getParameter("name of the textfield");
    String sPassword=request.getParameter("name of the textfield");
    after executeQuery() statement
    int exist=0;
    while(rs.next())
    String sUserId= rs.getString("username");
    String sPass_wd= rs.getString("password");
    if(sUserId.equals(sUsername) && sPass_wd.equals(sPassword))
    exist=1;
    if(exist==1)
    out.println("user exist");
    else
    out.println("not exist");

  • HT4906 how to import photos from photo stream into an event?

    How to import photos from photo stream into an event?

    How to import photos from photo stream into an event?
    In iPhoto 9.4.3 the following works:
    If you have not auto imported the photos from the Photo Stream, as Larry suugests, select the photos that you want to import in the Photo Stream, and drag them to the "Events" view in the Source List. They will be imported as new events, auto split with respect to your preferences.
    Regards
    Léonie

  • I am running Windows 7.  I have 250 photos from a trip that I want to load to the iPad v 6.1.3.1 and show as slide show (in named order).  I can not see any recent remarks regarding how to keep them from being loaded in date order.

    I am running Windows 7.  I have 250 photos from a trip that I want to load to the iPad v 6.1.3.1 and show as slide show (in named order).  I can not see any recent remarks regarding how to keep them from being loaded in date order

    By default the photos will be sorted by the date modified.
         iOS: Understanding photo sorting
    Edit (touch) them in the order you want them to be shown.

  • HT201406 1st. Gen iPad question:  the touch keyboard does not appear when attempting to input data into data fields - this happens while using all apps, ex. Notes, Google, Pages, etc..

    1st. Gen iPad question:  the touch keyboard does not appear when attempting to input data into data fields - this happens while using all apps, ex. Notes, Google, Pages, etc.. The cursor prompt is present.  Tapping screen just brings up the option to: "Select   Select All   Paste."   I have rebbooted with no change. 
    Message was edited by: Jimfromutah
    The problem was my connected bluetooth keyboard.

    1st. Gen iPad question:  the touch keyboard does not appear when attempting to input data into data fields - this happens while using all apps, ex. Notes, Google, Pages, etc.. The cursor prompt is present.  Tapping screen just brings up the option to: "Select   Select All   Paste."   I have rebbooted with no change. 
    Message was edited by: Jimfromutah
    The problem was my connected bluetooth keyboard.

  • WHAT IS PROCEDURE TO UPDATE DATA INTO DATA TARGETS?

    Hi,
    Experts,
    WHAT IS PROCEDURE TO UPDATE DATA INTO DATA TARGETS?
    FULL and DELTA.
    Thnx&regds,
    prerna

    Hi...........
    For both BW 3.X and BI 7.0........replicate the datasource in the BW side and activate it.............if require create Generic datasource and replicate it........
    In BW 3.X.....
    1) Create infosource
    2) Create transfer rules and update rules
    3) Create an infopackage...............with update mode full update( Update tab),in the Processing tab you can make it PSA and then into data targets........only data targets..........or PSA and data targets parallely...............
    For Delta load..........1),2) is same...........
    3) then you have to create a full Upload IP...........and you have to run it first..........
    4) Then you have run a init IP without data transfer to det the init flag
    5) then run Delta IP........
    Init and delta upload will be always without selection......
    BI 7.0 :
    1) Create an infopackage and load data till PSA..............
    2) create transformation between PSA and data targets.....
    3) The create a DTP and load data to the target.............depending on your requirements you DTP can be full or delta..........
    Check the following links :
    http://help.sap.com/saphelp_nw2004s/helpdata/en/43/02c52ce87e2c9ce10000000a1553f6/frameset.htm
    http://help.sap.com/search/highlightContent.jsp
    http://help.sap.com/search/highlightContent.jsp
    http://help.sap.com/saphelp_nw70/helpdata/EN/b9/2d9778476b11d4b2b40050da4c74dc/frameset.htm
    Hope this helps you......
    Regards,
    Debjani..........
    Edited by: Debjani  Mukherjee on Sep 14, 2008 1:43 PM

  • How to calculate AGE from two different date fields

    hi
    I need to calculate AGE from two different date fields.
    Can some help me how to do, when i try to do substraction formula it is showing error.
    Thank You
    Manu

    Manu wrote:
    Hi
    Both fields are in date format only, i need to calculate no . of days between two different dates
    Thanks
    ManuThe reason for the question about the format of the column is because the simplest solution only works on DATE columns. Others have mentioned this here, but if you want the difference between two date fields, you can use this formula:
    TIMESTAMPDIFF(SQL_TSI_DAY, date_column1, date_column2)
    The above being said, you still didn't tell me what you did, or what error message you received. So again, if the above formula didn't work, what did you do? Where did you put the formula? What was the exact syntax you used? What was the error message you got?
    Please don't make us work more than we need to. Answer all the questions in your next post. Thanks.

  • How to Calculate Duration from Date Columns

    Hello,
    I would like to calculate duration from date columns. Using the following query
    SELECT DISTINCT
    EVENT_ID,
    To_Char(RU.START_TIME, 'HH24:MI') START_TIME,
    To_Char(RU.END_TIME, 'HH24:MI') END_TIME
    FROM ROOM_USAGE RU
    What I need is to subtract START_TIME from END_TIME and result should be in minutes.
    Many Thanks,

    But, i think you need to calculate the number of days if the days are not same -
    satyaki>
    satyaki>
    satyaki>
    satyaki>with ru
    2 as
    3 (
    4 select '05-JAN-2007 15:10:20' start_time, '07-JAN-2007 19:20:20' end_time from dual
    5 union all
    6 select '08-JAN-2007 05:10:20' start_time, '07-JAN-2007 07:07:20' end_time from dual
    7 )
    8 select ru.start_time, ru.end_time, SUBSTR(numtodsinterval(to_date(RU.END_TIME,'DD-MON-YYYY HH24:MI:SS')-to_date(RU.START_TIME,'DD-MON-YYYY HH24:MI:SS'), 'DAY'), 12, 8) duration
    9 from ru;
    START_TIME END_TIME DURATION
    05-JAN-2007 15:10:20 07-JAN-2007 19:20:20 04:09:59
    08-JAN-2007 05:10:20 07-JAN-2007 07:07:20 22:03:00
    satyaki>
    Or, Am i missing anything?
    Regards.
    Satyaki De.
    is it possible to to add the duration? making the total hours to 26:12 (twentysix hours and twelve minutes)

  • Convert data into Date Format imported from MS SQL Server.

    I have imported Data from MS SQL Server. The "Date Column" received in number format like 41017.6361109954. How can i convert it into Date in Oracle SQL.
    If i import same Data in Excel and change the Column Type to Date. It changes successfully. But in Oracle, I tried To_Date function with different parameters but it didn't work.
    Edited by: XAVER on Apr 22, 2012 2:31 AM

    XAVER wrote:
    The actual date for 41017.6361109954 is 22-Apr-2012 but its showing 20-APR-2082It looks like offset is January 1, 2000:
    select timestamp '2000-01-01 00:00:00' + numtodsinterval(41017.6361109954,'day') from dual;
    20-APR-12 03.15.59.990002560 PM
    SQL> SY.

  • How can I recover from a Botched BATCH DATE CHANGE in iPhoto?

    Botched Batch Date Change iPhoto08
    Short Story: Intending to change the date for one photo I managed to change the dates for all 8,525 images in my iPhoto08 library to the SAME DATE!! I found that the original creation dates were saved in the in the Modified field that appears in the Photo Info Window / File metadata subsection. I would like some help figuring out how to set the Date Created to this File Modified Date that appears in the Photo Info Window.
    GORY DETAILS:
    I used iPhoto08/ Photos menu / BATCH CHANGE... /“Set DATE to 20100723 1:20:54 PM” with “Modify original files” checked. iPhoto changed all 8,525 images to the same date.
    I now realize I should have used Photos menu / Adjust Date and Time ... But the damage was already done. Unfortunately there was no Edit menu / Undo for this operation. ALL 8,525 images have the same date. I checked in the the iPhoto Information sidebar--same date all images.
    Next, as a test, I dragged an image to the desktop and opened it in Graphic Converter7.0.3. The same date “20100723 1:20:54 PM” appeared in the Image Browser List /”Date Created”, “Date Modified”, “Date Captured” metadata fields.
    The following appeared in the Graphic Converter
    Image Preview sidebar (subWindow) going left to right
    Image menu/button
    Date and Time: Friday, July 23, 2010 1:20:54 PM PT
    Exif menu/button
    File date and time: 2010:07:23 13:20:54
    Date and time of original data generation: 2010:07:23 13:20:54
    Unknown tag (36868): 2010:07:23 13:20:54 <- significant?
    ExifTool menu/button
    ExifTool Version Number:8.40
    Warning: [minor] Suspicious MakerNotes offset for tag 0x9001
    ----System----
    File Modification Date/Time: 2010:07:23 13:20:54-07:00
    ----IFDO----
    Modify Date: 2010:07:23 13:20:54
    ----ExifIFD----
    Date/Time Original: 2010:07:23 13:20:54
    Create Date: 2010:07:23 13:20:54
    <<<<<<OH MY GOD >>>>>> the BATCH CHANGE / SET DATE not only RESET the date for EVERY IMAGE in my library, it also changed the date metadata EVERYWHERE inside each individual image file.
    Actually it's my Mom and Dad's iPhoto library containing all the kids and grand kids pictures, family trips, important events, everything. There is no backup. I feel as if I have tipped over a file cabinet containing all our photos. Our “date and event” organized 8,525 image iPhoto library was now as useful as a giant shoebox. On second thought, a shoe box full of real photo prints would be more useful than my iPhoto library because the prints would have the print date stamped on them.
    At this point feeling desperate I closed my eyes and said a quick prayer to Saint Rita - Patron Saint of the Impossible.
    I returned to iPhoto .................and noticed the Show Photo Info MENU item in the Photo Menu.
    I selected it.
    And Low and behold,
    in the Photo Info WINDOW,
    under the Meta data File SUBSECTION, the correct photo creation date appeared -->" Modified: 20071002 05:46:07 PM" I checked different photos ... They all had different FILE MODIFIED dates. These dates were/are the old creation dates! My prayers were answered: THANK YOU SAINT RITA!
    But now I am really stumped! This File Modified Date seems to be some kind of external metadata that is indexed or keyed to each image. How is this metadata stored in the iPhoto library? How can I access this File Modified date? I now turn to you GREAT iPhoto WIZARDS. Pray tell, how can I set the “Creation Date to the file Modified Date” that appears in the Photo Info Window as a (scriptable?) batch process.
    I am on my knees for this one...please help. we have iphoto11 but afraid to upgrade to it. until i know more i don't want to loose this Modified Date metadata.

    thanks for the quick response...
    no simple solution because no backup to restore from
    iPhoto seems to be using file metadata as some sort of index key in the
    Photo Info Window. open up the iphoto library package and take a look at
    the .xml file -- ModDate is used everywhere. hoping to export this data and merge/join it to
    each image.
    still trying to figure it out.
    thanks,
    Tom

Maybe you are looking for