Analytic functions using window date range

Here are my requirements:
For each FLT# Get the MIN and MAX CRSG_DT within 2½ hours period into the same bucket for each day
I am using Oracle 10gR2
CREATE TABLE TST_ANAL
FLT_NBR VARCHAR2(10),
CRSG_DT DATE ,
TNBR VARCHAR2(14)
INSERT INTO TST_ANAL ( FLT_NBR, CRSG_DT, TNBR) VALUES (
'0002947', TO_Date( '03/01/2007 07:31:57 PM', 'MM/DD/YYYY HH:MI:SS AM'), 'D2007070013438');
INSERT INTO TST_ANAL ( FLT_NBR, CRSG_DT, TNBR) VALUES (
'0002947', TO_Date( '03/01/2007 08:31:02 PM', 'MM/DD/YYYY HH:MI:SS AM'), 'D2007070013446');
INSERT INTO TST_ANAL ( FLT_NBR, CRSG_DT, TNBR) VALUES (
'0002947', TO_Date( '03/01/2007 05:30:34 PM', 'MM/DD/YYYY HH:MI:SS AM'), 'D2007070013440');
INSERT INTO TST_ANAL ( FLT_NBR, CRSG_DT, TNBR) VALUES (
'0002947', TO_Date( '03/01/2007 05:32:07 PM', 'MM/DD/YYYY HH:MI:SS AM'), 'D2007070013427');
INSERT INTO TST_ANAL ( FLT_NBR, CRSG_DT, TNBR) VALUES (
'0002947', TO_Date( '03/01/2007 05:32:40 AM', 'MM/DD/YYYY HH:MI:SS AM'), 'D2007070013433');
INSERT INTO TST_ANAL ( FLT_NBR, CRSG_DT, TNBR) VALUES (
'0002947', TO_Date( '03/01/2007 05:35:40 AM', 'MM/DD/YYYY HH:MI:SS AM'), 'D2007070013429');
INSERT INTO TST_ANAL ( FLT_NBR, CRSG_DT, TNBR) VALUES (
'0002947', TO_Date( '03/01/2007 07:32:45 AM', 'MM/DD/YYYY HH:MI:SS AM'), 'D2007070013434');
INSERT INTO TST_ANAL ( FLT_NBR, CRSG_DT, TNBR) VALUES (
'0002947', TO_Date( '03/01/2007 07:32:50 AM', 'MM/DD/YYYY HH:MI:SS AM'), 'D200707001323');
COMMIT;
The desired output:
FLT_NBR     CRSG_DT     MIN     MAX Bucket
2947     3/1/2007 5:32     3/1/2007 5:32     3/1/2007 7:32     1
2947     3/1/2007 5:35     3/1/2007 5:32     3/1/2007 7:32     1
2947     3/1/2007 7:32     3/1/2007 5:32     3/1/2007 7:32     1
2947     3/1/2007 7:32     3/1/2007 5:32     3/1/2007 7:32     1
2947     3/1/2007 17:30     3/1/2007 17:30     3/1/2007 19:31     2
2947     3/1/2007 17:32     3/1/2007 17:30     3/1/2007 19:31     2
2947     3/1/2007 19:31     3/1/2007 17:30     3/1/2007 19:31     2
2947     3/1/2007 20:31     3/1/2007 20:31     3/1/2007 20:31     3
I am sure an Analytic query is the optimal solution. I need help creating the query. So far, I have attempted to use the min() and then both First_value() over partition clause but I do not know how to specify the window clause using a logical date range to calculate the 2 1/2 hours.
A lot of documentation states that I can use an expression for the range between but I cannot get one even compile
Need Help or documentation that provide some assistance
Thanks

I can get to the min and max, but for bucket, row_number() doesn't take the same windowing logical offset.
SQL> select flt_nbr,
  2         crsg_dt,
  3         min(crsg_dt) over (partition by flt_nbr,
  4                                         trunc(crsg_dt)
  5                            order by crsg_dt range between (2.5/24) preceding and (2.5/24) following) mn,
  6         max(crsg_dt) over (partition by flt_nbr,
  7                                         trunc(crsg_dt)
  8                            order by crsg_dt range between (2.5/24) preceding and (2.5/24) following) mx
  9  from tst_anal
10  /
FLT_NBR    CRSG_DT              MN                   MX
0002947    01-MAR-2007 05:32:40 01-MAR-2007 05:32:40 01-MAR-2007 07:32:50
0002947    01-MAR-2007 05:35:40 01-MAR-2007 05:32:40 01-MAR-2007 07:32:50
0002947    01-MAR-2007 07:32:45 01-MAR-2007 05:32:40 01-MAR-2007 07:32:50
0002947    01-MAR-2007 07:32:50 01-MAR-2007 05:32:40 01-MAR-2007 07:32:50
0002947    01-MAR-2007 17:30:34 01-MAR-2007 17:30:34 01-MAR-2007 19:31:57
0002947    01-MAR-2007 17:32:07 01-MAR-2007 17:30:34 01-MAR-2007 19:31:57
0002947    01-MAR-2007 19:31:57 01-MAR-2007 17:30:34 01-MAR-2007 20:31:02
0002947    01-MAR-2007 20:31:02 01-MAR-2007 19:31:57 01-MAR-2007 20:31:02
8 rows selected.
SQL> Had to user FIRST_VALUE and then calculate row_number() on that for bucket.
SQL>
SQL> select flt_nbr, crsg_dt, mn, mx, dense_rank() over (partition by flt_nbr,
  2                                                             trunc(crsg_dt)
  3                                                      order by rn) bucket
  4  from (select flt_nbr,
  5               crsg_dt,
  6               min(crsg_dt) over (partition by flt_nbr,
  7                                               trunc(crsg_dt)
  8                                  order by crsg_dt range between (2.5/24) preceding and (2.5/24) following) mn,
  9               max(crsg_dt) over (partition by flt_nbr,
10                                               trunc(crsg_dt)
11                                  order by crsg_dt range between (2.5/24) preceding and (2.5/24) following) mx,
12               FIRST_VALUE(crsg_dt) over (partition by flt_nbr,
13                                                       trunc(crsg_dt)
14                                          order by crsg_dt range between (2.5/24) preceding and (2.5/24) following) rn
15        from tst_anal)
16  /
FLT_NBR    CRSG_DT              MN                   MX                       BUCKET
0002947    01-MAR-2007 05:32:40 01-MAR-2007 05:32:40 01-MAR-2007 07:32:50          1
0002947    01-MAR-2007 05:35:40 01-MAR-2007 05:32:40 01-MAR-2007 07:32:50          1
0002947    01-MAR-2007 07:32:45 01-MAR-2007 05:32:40 01-MAR-2007 07:32:50          1
0002947    01-MAR-2007 07:32:50 01-MAR-2007 05:32:40 01-MAR-2007 07:32:50          1
0002947    01-MAR-2007 17:30:34 01-MAR-2007 17:30:34 01-MAR-2007 19:31:57          2
0002947    01-MAR-2007 17:32:07 01-MAR-2007 17:30:34 01-MAR-2007 19:31:57          2
0002947    01-MAR-2007 19:31:57 01-MAR-2007 17:30:34 01-MAR-2007 20:31:02          2
0002947    01-MAR-2007 20:31:02 01-MAR-2007 19:31:57 01-MAR-2007 20:31:02          3
8 rows selected.
SQL> Cheers
Sarma.

Similar Messages

  • Which BW variable is used for date(range) when creating a portal service

    Hi,
    Can any one please let me know which BW variable is to be used for date(range) when creating a portal service for searching based on dates.
    Thanks
    Abhai

    Hi Arun,
    its just a portal service which would be called when  searching a document created on a particular date or betwwen a range of date.so what i require is which BW variable to be used when handling range.As for variable technical name we use VAR_NAME_I  and for single value variable we VAR_VALUE_EXT_I
    in the similar manner i want BW variable to be used for range of values.
    Thanks
    Abhai

  • Function module find date Range input for scheduling a job

    hi i have created a program for scheduling a back ground job for  purchase order extract in that i have to get the last 7 days records when i schedule it on every sunday can any one tell me the function module which satisfies the requirment
    Date Range input in my program to be calculated for past 7 days from current date (ie from Sunday to Saturday of the week.)

    Hi,
    You can do it simply by
           v_cdate TYPE sy-datum,    " current system date
           v_cdate = sy-datum - 7.         " take date 7 days before current date
    Pass this  v_cdate in your logic
    Hope it will help you.
    Thanks
    Arun Kayal

  • Using SSRS Date Range- Data Not shown for date greater than by Analysis Services

    Hello Friends,
     I am using Date Range filters(Start and End Date) in my SSRS Report. The Problem is that if i am using the start date will be today, then the end date will be the future date by using Analysis Service as my Data Source, the report is not generated.
    I don't know why it happens? If I give the date range filters before the current date, then the report will shown.
    The problem is that the future date is not in my database. Could you please answer for this. I am struck in here,.
    Table contains : 1-7-14 ,
    2-7-14,
    3-7-14,
    If my Date Range will be 1st to 3 of 7th month, then the report shows the data.
    if my date starts with 1st of the 7th month and ends in the future, then the report will not shown the 2nd and 3rd records...
    Please teach me why?

    Your question should be posted to the appropriate MSDN forum.  This forum is for questions regarding Microsoft Certifications.

  • How can i use analytic function on these data

    hi ,
    i have the following data:
    id start end
    1 11-oct-2006 03:00:34 12-oct-2006 09:00:10
    1 09-oct-2006 05:00:23 11-oct-2006 03:00:34
    1 08-oct-2006 03:00:23 09-oct-2006 05:00:23
    2 11-oct-2006 11:00:00 11-oct-2006 14:00:00
    1 08-oct-2006 03:00:00 08-oct-2006 04:00:00
    my end results shld be
    id start end
    1 08-oct-2006 05:00:23 12-oct-2006 09:00:10
    2 11-oct-2006 11:00:00 11-oct-2006 14:00:00
    1 08-oct-2006 03:00:00 08-oct-2006 04:00:00
    pls advise
    tks & rdgs

    Mohana ,
    I think Elic's solution can be used here also
    (Group by preserving the order
    sql>select * from t;
    ID ST ED 
    1  11-OCT-06 03.00.34.000000 AM  12-OCT-06 09.00.10.000000 AM 
    1  09-OCT-06 05.00.23.000000 AM  11-OCT-06 03.00.34.000000 AM 
    1  08-OCT-06 04.00.23.000000 AM  09-OCT-06 05.00.23.000000 AM 
    2  11-OCT-06 11.00.00.000000 AM  11-OCT-06 12.00.00.000000 PM 
    1  08-OCT-06 03.00.00.000000 AM  08-OCT-06 04.00.00.000000 AM 
    sql>
    select id,min(st) st,max(ed) ed
    from(
    select id,st,ed, sum(grp) over(order by st) sm
    from(
    select id,st,ed,decode(lag(ed) over(order by st),st,0,1) grp
    from t))
    group by id,sm;
    ID ST ED 
    1  08-OCT-06 03.00.00.000000 AM  08-OCT-06 04.00.00.000000 AM 
    1  08-OCT-06 04.00.23.000000 AM  12-OCT-06 09.00.10.000000 AM 
    2  11-OCT-06 11.00.00.000000 AM  11-OCT-06 12.00.00.000000 PM
    Message was edited by:
            jeneesh                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Single Date Parameter, but using a date range for selection

    Post Author: fireman204
    CA Forum: Formula
    I'm fairly new to Crystal Reports, so be gentle with me.  I have a report that has 4 parameters.  The report asks for data for a specific month, the YTD data to the end of the selected month, and the same data from the previous year.  It seems there should be a way to enter a single parameter (ie., 2007-4-1), and off that date select all the data for the month, the current year to the end of that month, and then the data from the previous year for the same period.  I know this will be a formula field needed to select the data, but not sure how to get there from here.  Any ideas?  Thanks in advance!

    Post Author: SKodidine
    CA Forum: Formula
    It should be possible for you to create just one parameter to have the user input a single date and then create formulae to create the begin and end dates for the month, YTD and PYTD.  You can then use these formulae for record selection criteria.
    For example, if the user inputs a date of 2007-04-01 for the single parameter then create formulae such as:
    beginmonth
    datevar beginmonth;
    beginmonth := date(year({?My Parameter}),month({?My Parameter}),01);
    endmonth
    datevar endmonth;
    endmonth := cdLastDayOfMonth ({?My Parameter});
    To use the cdlastdayofmonth function, In the formula workshop window, click on "Repository Custom Functions" then under CRYSTAL and DATE right click on cdlastdayofmonth and click on ADD TO REPORT.  Once that is done, then create the above "endmonth" formula.  You should see this new function in your formula workshop window in the FUNCTIONS window under CUSTOM FUNCTIONS.
    beginytd
    datevar beginytd := date(year(currentdate),01,01);
    endytd
    datevar endytd;
    endytd := cdLastDayOfMonth ({?My Parameter});
    beginpytd
    datevar beginpytd := date((year(currentdate)-1),01,01);
    endpytd
    evaluateafter({@endytd});
    datevar endytd;
    datevar endpytd;
    endpytd := date(year(endytd)-1,month(endytd),day(endytd));
    In your record selection criteria, you can use the above formulae like this:
    in {@beginmonth} to {@endmonth}
    or
    in {@beginytd} to {@endytd}
    or
    in {@beginpytd} to {@endpytd};
    This is one way of doing it, perhaps others might pitch in with a more efficient way.

  • How can I use a date range in a list KPI value expression

    I am trying to create a series of status indicators for a document library in SharePoint 2010. I've made a status list for this. One of the desired KPI's is to show the percentage of documents that must be revised and approved within the next two
    months.
    I have a field which logs the next approval date (last approval date plus one year). In the standard form for the KPI I can set the value expression to return the percentage of documents to be reviewed between [Today] and a date that I fill
    in by hand (see image below). But I haven't yet been able to have the target date (two months from today) change dynamically. Is there a way to have the second date increment via a calculation here? Or do I need to use a recurring workflow to do this?
    Any help would be greatly appreciated - also if this post should be elsewhere. I am not a programmer, and just beginning to learn to make use of many of SharePoint's functions.
    Cheers,
    Russ Herald

    I'm not certain if you can use formulas here but if you can use the standard SharePoint Field Formulas you could try the following:
    For the second date could you just put: [Today]+60 to add 60 days to the current date
    Or to work with actual months you could possibly use: =DATE(YEAR([Today]),MONTH([Today])+2,DAY([Today])) to add exactly two months.
    Reference:
    https://msdn.microsoft.com/en-us/library/office/bb862071(v=office.14).aspx#sectionSection2

  • Function module for date ranges

    Hi all,
           Is there any function module to display all the dates in between start date and end date. Or provide blocke code for this.
    Ex : If i have given nov 5th 2008 and nov 10th 2008 as input parameters.
           Output should be nov 5th 2008, nov 6th 2008,nov 7th 2008,nov 8th 2008,nov 9th 2008,nov 10th 2008,
    Please help me out in this regard.
    thanks
    naidu

    Hi Omkaram,
           Thank you verymuch for your code. That link is useful for me. I have rewarded you.
           But when i'm using the same code in my function module its not working.
           I have done the debugging the function module is not taking the input.
          Ex : itab[] = lt_date[].
          when i'm doing debugging the input parameter lt_date has no value.
          I dont know why it is.
          Can you help me please.
       Regards
       Naidu

  • Using Parameter Date Range Values in Report

    Post Author: rsteeg
    CA Forum: General
    i would like to include the selected start and end dates on my report to display the range of the report.  I cannot recall how to do it.  Can any one help?  I am using CR X.

    Post Author: Crystal Fire
    CA Forum: General
    "All Dates Between "+ ToText(Minimum({?Your Date Field}),"M/d/yyyy")" and "ToText(Maximum({?Your Date Field}),"M/d/yyyy")

  • Using analytical function to calculate concurrency between date range

    Folks,
    I'm trying to use analytical functions to come up with a query that gives me the
    concurrency of jobs executing between a date range.
    For example:
    JOB100 - started at 9AM - stopped at 11AM
    JOB200 - started at 10AM - stopped at 3PM
    JOB300 - started at 12PM - stopped at 2PM
    The query would tell me that JOB1 ran with a concurrency of 2 because JOB1 and JOB2
    were running started and finished within the same time. JOB2 ran with the concurrency
    of 3 because all jobs ran within its start and stop time. The output would look like this.
    JOB START STOP CONCURRENCY
    === ==== ==== =========
    100 9AM 11AM 2
    200 10AM 3PM 3
    300 12PM 2PM 2
    I've been looking at this post, and this one if very similar...
    Analytic functions using window date range
    Here is the sample data..
    CREATE TABLE TEST_JOB
    ( jobid NUMBER,
    created_time DATE,
    start_time DATE,
    stop_time DATE
    insert into TEST_JOB values (100, sysdate -1, to_date('05/04/08 09:00:00','MM/DD/YY hh24:mi:ss'), to_date('05/04/08 11:00:00','MM/DD/YY hh24:mi:ss'));
    insert into TEST_JOB values (200, sysdate -1, to_date('05/04/08 10:00:00','MM/DD/YY hh24:mi:ss'), to_date('05/04/08 13:00:00','MM/DD/YY hh24:mi:ss'));
    insert into TEST_JOB values (300, sysdate -1, to_date('05/04/08 12:00:00','MM/DD/YY hh24:mi:ss'), to_date('05/04/08 14:00:00','MM/DD/YY hh24:mi:ss'));
    select * from test_job;
    JOBID|CREATED_TIME |START_TIME |STOP_TIME
    ----------|--------------|--------------|--------------
    100|05/04/08 09:28|05/04/08 09:00|05/04/08 11:00
    200|05/04/08 09:28|05/04/08 10:00|05/04/08 13:00
    300|05/04/08 09:28|05/04/08 12:00|05/04/08 14:00
    Any help with this query would be greatly appreciated.
    thanks.
    -peter

    after some checking the model rule wasn't working exactly as expected.
    I believe it's working right now. I'm posting a self-contained example for completeness sake.I use 2 functions to convert back and forth between epoch unix timestamps, so
    I'll post them here as well.
    Like I said I think this works okay, but any feedback is always appreciated.
    -peter
    CREATE OR REPLACE FUNCTION date_to_epoch(p_dateval IN DATE)
    RETURN NUMBER
    AS
    BEGIN
    return (p_dateval - to_date('01/01/1970','MM/DD/YYYY')) * (24 * 3600);
    END;
    CREATE OR REPLACE FUNCTION epoch_to_date (p_epochval IN NUMBER DEFAULT 0)
    RETURN DATE
    AS
    BEGIN
    return to_date('01/01/1970','MM/DD/YYYY') + (( p_epochval) / (24 * 3600));
    END;
    DROP TABLE TEST_MODEL3 purge;
    CREATE TABLE TEST_MODEL3
    ( jobid NUMBER,
    start_time NUMBER,
    end_time NUMBER);
    insert into TEST_MODEL3
    VALUES (300,date_to_epoch(to_date('05/07/2008 10:00','MM/DD/YYYY hh24:mi')),
    date_to_epoch(to_date('05/07/2008 19:00','MM/DD/YYYY hh24:mi')));
    insert into TEST_MODEL3
    VALUES (200,date_to_epoch(to_date('05/07/2008 09:00','MM/DD/YYYY hh24:mi')),
    date_to_epoch(to_date('05/07/2008 12:00','MM/DD/YYYY hh24:mi')));
    insert into TEST_MODEL3
    VALUES (400,date_to_epoch(to_date('05/07/2008 10:00','MM/DD/YYYY hh24:mi')),
    date_to_epoch(to_date('05/07/2008 14:00','MM/DD/YYYY hh24:mi')));
    insert into TEST_MODEL3
    VALUES (500,date_to_epoch(to_date('05/07/2008 11:00','MM/DD/YYYY hh24:mi')),
    date_to_epoch(to_date('05/07/2008 16:00','MM/DD/YYYY hh24:mi')));
    insert into TEST_MODEL3
    VALUES (600,date_to_epoch(to_date('05/07/2008 15:00','MM/DD/YYYY hh24:mi')),
    date_to_epoch(to_date('05/07/2008 22:00','MM/DD/YYYY hh24:mi')));
    insert into TEST_MODEL3
    VALUES (100,date_to_epoch(to_date('05/07/2008 09:00','MM/DD/YYYY hh24:mi')),
    date_to_epoch(to_date('05/07/2008 23:00','MM/DD/YYYY hh24:mi')));
    commit;
    SELECT jobid,
    epoch_to_date(start_time)start_time,
    epoch_to_date(end_time)end_time,
    n concurrency
    FROM TEST_MODEL3
    MODEL
    DIMENSION BY (start_time,end_time)
    MEASURES (jobid,0 n)
    (n[any,any]=
    count(*)[start_time<= cv(start_time),end_time>=cv(start_time)]+
    count(*)[start_time > cv(start_time) and start_time <= cv(end_time), end_time >= cv(start_time)]
    ORDER BY start_time;
    The results look like this:
    JOBID|START_TIME|END_TIME |CONCURRENCY
    ----------|---------------|--------------|-------------------
    100|05/07/08 09:00|05/07/08 23:00| 6
    200|05/07/08 09:00|05/07/08 12:00| 5
    300|05/07/08 10:00|05/07/08 19:00| 6
    400|05/07/08 10:00|05/07/08 14:00| 5
    500|05/07/08 11:00|05/07/08 16:00| 6
    600|05/07/08 15:00|05/07/08 22:00| 4

  • Using Date Range parameter in Subreport Selection Formula

    I have a subreport which includes this line in the selection formula:
    {Production.Date} = {?Pm-?DateRange}
    {?Pm-?DateRange} appears in the Subreport Links window, so it seems like it should work.
    The DateRange parameter is set by the user in the Main report.
    But the subreport returns no records.
    I tried this:
    In the Main report I created a StartDate and a StopDate field from {?Pm-?DateRange} .
    Then in the subreport selection formula I used these two formula fields like this:
    {Production.Date} >= @StartDate
    and
    {Production.Date} <= @StopDate
    This works!
    So I have found a workaround, but still, I don't understand why the original code {Production.Date} = {?Pm-?DateRange} returns no records.
    Thanks,
    Art

    Hi Art,
    You cannot use a date range parameter directly in the subreport's record selection formula.
    You'll need to create a formula in the Main report like this:
    Minimum(?DateRange) //This gives the start date
    Maximum(?DateRange) //This gives the end date
    Then send these formulas as parameters to subreport for use in the record selection formula.
    I think you've already got this figured out anyway!
    -Abhilash

  • Searching Requisitions using Data ranges in iProcurement supplier search

    Hi,
    We are using the iProcurement 11.5.10.2 version. My client wants to search the requisitions using the Date ranges under Supplier Search window in iProcurement as we normally search in the Requisition Summary Window.
    Can any one help how to go further on this?
    Regards,
    Kevin.
    Edited by: user10960960 on Apr 7, 2009 12:39 PM

    Dear All,
    Any update on my requirement

  • Replacing Oracle's FIRST_VALUE and LAST_VALUE analytical functions.

    Hi,
    I am using OBI 10.1.3.2.1 where, I guess, EVALUATE is not available. I would like to know alternatives, esp. to replace Oracle's FIRST_VALUE and LAST_VALUE analytical functions.
    I want to track some changes. For example, there are four methods of travel - Air, Train, Road and Sea. Would like to know traveler's first method of traveling and the last method of traveling in an year. If both of them match then a certain action is taken. If they do not match, then another action is taken.
    I tried as under.
    1. Get Sequence ID for each travel within an year per traveler as Sequence_Id.
    2. Get the Lowest Sequence ID (which should be 1) for travels within an year per traveler as Sequence_LId.
    3. Get the Highest Sequence ID (which could be 1 or greater than 1) for travels within an year per traveler as Sequence_HId.
    4. If Sequence ID = Lowest Sequence ID then display the method of travel as First Method of Travel.
    5. If Sequence ID = Highest Sequence ID then display the method of travel as Latest Method of Travel.
    6. If First Method of Travel = Latest Method of Travel then display Yes/No as Match.
    The issue is cells could be blank in First Method of Travel and Last Method of Travel unless the traveler traveled only once in an year.
    Using Oracle's FIRST_VALUE and LAST_VALUE analytical functions, I can get a result like
    Traveler | Card Issue Date | Journey Date | Method | First Method of Travel | Last Method of Travel | Match?
    ABC | 01/01/2000 | 04/04/2000 | Road | Road | Air | No
    ABC | 01/01/2000 | 15/12/2000 | Air | Road | Air | No
    XYZ | 01/01/2000 | 04/05/2000 | Train | Train | Train | Yes
    XYZ | 01/01/2000 | 04/11/2000 | Train | Train | Train | Yes
    Using OBI Answers, I am getting something like this.
    Traveler | Card Issue Date | Journey Date | Method | First Method of Travel | Last Method of Travel | Match?
    ABC | 01/01/2000 | 04/04/2000 | Road | Road | <BLANK> | No
    ABC | 01/01/2000 | 15/12/2000 | Air | <BLANK> | Air | No
    XYZ | 01/01/2000 | 04/05/2000 | Train | Train | <BLANK> | No
    XYZ | 01/01/2000 | 04/11/2000 | Train | <BLANK> | Train | No
    Above, for XYZ traveler the Match? clearly shows a wrong result (although somehow it's correct for traveler ABC).
    Would appreciate if someone can guide me how to resolve the issue.
    Many thanks,
    Manoj.
    Edited by: mandix on 27-Nov-2009 08:43
    Edited by: mandix on 27-Nov-2009 08:47

    Hi,
    Just to recap, in OBI 10.1.3.2.1, I am trying to find an alternative way to FIRST_VALUE and LAST_VALUE analytical functions used in Oracle. Somehow, I feel it's achievable. I would like to know answers to the following questions.
    1. Is there any way of referring to a cell value and displaying it in other cells for a reference value?
    For example, can I display the First Method of Travel for traveler 'ABC' and 'XYZ' for all the rows returned in the same column, respectively?
    2. I tried RMIN, RMAX functions in the RDP but it does not accept "BY" clause (for example, RMIN(Transaction_Id BY Traveler) to define Lowest Sequence Id per traveler). Am I doing something wrong here? Why can a formula with "BY" clause be defined in Answers but not the RPD? The idea is to use this in Answers. This is in relation to my first question.
    Could someone please let me know?
    I understand that this thread that I have posted is related to something that can be done outside OBI, but still would like to know.
    If anything is not clear please let me know.
    Thanks,
    Manoj.

  • Oracle Analytic function tuning

    Hi all,
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
    PL/SQL Release 10.2.0.3.0 - Production
    CORE 10.2.0.3.0 Production
    TNS for IBM/AIX RISC System/6000: Version 10.2.0.3.0 - Productio
    NLSRTL Version 10.2.0.3.0 - Production
    I have a query which has analytic function uses large space on temporary tablespace resulting in direct path temp read and direct path temp write wait events taking too much time. Is there any way to tune such query?
    Thanks in advance.

    user9074365 wrote:
    Hi all,
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
    PL/SQL Release 10.2.0.3.0 - Production
    CORE 10.2.0.3.0 Production
    TNS for IBM/AIX RISC System/6000: Version 10.2.0.3.0 - Productio
    NLSRTL Version 10.2.0.3.0 - Production
    I have a query which has analytic function uses large space on temporary tablespace resulting in direct path temp read and direct path temp write wait events taking too much time. Is there any way to tune such query?
    With your version of Oracle, and high-volumes of data going through analytic function, it's likely that this blog note applies. You may need an upgrade or special patch. http://jonathanlewis.wordpress.com/2009/09/07/analytic-agony/
    Regards
    Jonathan Lewis

  • Reports 6i and analytical function

    hi
    I have this query which wrks fine in TOAD
    SELECT rvt.receipt_num srv_no, rvt.supplier supplier,
                    rvt.transaction_date srv_date, inv.segment1 item_no,
                    rvt.item_desc item_description, hrov.NAME,               
                    (   SUBSTR (v.standard_industry_class, 1, 1)
                     || '-'
                     || po_headers.segment1
                     || '-'
                     || TO_CHAR (po_headers.creation_date, 'RRRR')
                    ) po_no,
                    po_headers.creation_date_disp po_date,   
                          (  (rvt.currency_conversion_rate * po_lines.unit_price)
                     * rvt.transact_qty
                    )aMOUNT  ,
    ----Analytic function used here                      
            SUM(          (  (rvt.currency_conversion_rate * po_lines.unit_price)
                     * rvt.transact_qty)) over(partition by hrov.NAME) SUM_AMOUNT,                                                                                 
                    (SELECT SUM (mot.on_hand)
                       FROM mtl_onhand_total_mwb_v mot
                      WHERE inv.inventory_item_id = mot.inventory_item_id
                        --  AND INV.ORGANIZATION_ID=MOT.ORGANIZATION_ID
                        AND loc.inventory_location_id = mot.locator_id
                        AND loc.organization_id = mot.organization_id
                        AND rvt.locator_id = mot.locator_id) onhand
               FROM rcv_vrc_txs_v rvt,
                    mtl_system_items_b inv,
                    mtl_item_locations loc,
                    hr_organization_units_v hrov,
                    po_headers_v po_headers,
                    ap_vendors_v v,
                    po_lines_v po_lines
              WHERE inv.inventory_item_id(+) = rvt.item_id
                AND po_headers.vendor_id = v.vendor_id
                AND rvt.po_line_id = po_lines.po_line_id
                AND rvt.po_header_id = po_lines.po_header_id
                AND rvt.po_header_id = po_headers.po_header_id
                AND rvt.supplier_id = v.vendor_id
                AND inv.organization_id = hrov.organization_id
                AND rvt.transaction_type = 'DELIVER'
                AND rvt.inspection_status_code <> 'REJECTED'
                AND rvt.organization_id = inv.organization_id(+)
                AND to_char(to_date(rvt.transaction_date, 'DD/MM/YYYY'), 'DD-MON-YYYY') BETWEEN (:p_from_date)
                                                     AND NVL (:p_to_date,
                                                              :p_from_date
                AND rvt.locator_id = loc.physical_location_id(+)
                AND transaction_id NOT IN (
                       SELECT parent_transaction_id
                         FROM rcv_vrc_txs_v rvtd
                        WHERE rvt.item_id = rvtd.item_id
                          AND rvtd.transaction_type IN
                                      ('RETURN TO RECEIVING', 'RETURN TO VENDOR'))
                                      GROUP BY rvt.receipt_num , rvt.supplier ,
                    rvt.transaction_date , inv.segment1 ,
                    rvt.item_desc , hrov.NAME,v.standard_industry_clasS,po_headers.segment1,po_headers.creation_datE,
                    po_headers.creation_date_disp,inv.inventory_item_iD,loc.inventory_location_id,loc.organization_id,
                    rvt.locator_iD,rvt.currency_conversion_rate,po_lines.unit_price, rvt.transact_qty
    but it gives blank page in reports 6i
    could it be that reports 6i donot support analytical functionskindly guide another alternaive
    thanking in advance
    Edited by: makdutakdu on Mar 25, 2012 2:22 PM

    hi
    will the view be like
    create view S_Amount as SELECT rvt.receipt_num srv_no, rvt.supplier supplier,
                    rvt.transaction_date srv_date, inv.segment1 item_no,
                    rvt.item_desc item_description, hrov.NAME,               
                    (   SUBSTR (v.standard_industry_class, 1, 1)
                     || '-'
                     || po_headers.segment1
                     || '-'
                     || TO_CHAR (po_headers.creation_date, 'RRRR')
                    ) po_no,
                    po_headers.creation_date_disp po_date,   
                          (  (rvt.currency_conversion_rate * po_lines.unit_price)
                     * rvt.transact_qty
                    )aMOUNT  ,
    ----Analytic function used here                      
            SUM(          (  (rvt.currency_conversion_rate * po_lines.unit_price)
                     * rvt.transact_qty)) over(partition by hrov.NAME) SUM_AMOUNT,                                                                                 
                    (SELECT SUM (mot.on_hand)
                       FROM mtl_onhand_total_mwb_v mot
                      WHERE inv.inventory_item_id = mot.inventory_item_id
                        --  AND INV.ORGANIZATION_ID=MOT.ORGANIZATION_ID
                        AND loc.inventory_location_id = mot.locator_id
                        AND loc.organization_id = mot.organization_id
                        AND rvt.locator_id = mot.locator_id) onhand
               FROM rcv_vrc_txs_v rvt,
                    mtl_system_items_b inv,
                    mtl_item_locations loc,
                    hr_organization_units_v hrov,
                    po_headers_v po_headers,
                    ap_vendors_v v,
                    po_lines_v po_lines
              WHERE inv.inventory_item_id(+) = rvt.item_id
                AND po_headers.vendor_id = v.vendor_id
                AND rvt.po_line_id = po_lines.po_line_id
                AND rvt.po_header_id = po_lines.po_header_id
                AND rvt.po_header_id = po_headers.po_header_id
                AND rvt.supplier_id = v.vendor_id
                AND inv.organization_id = hrov.organization_id
                AND rvt.transaction_type = 'DELIVER'
                AND rvt.inspection_status_code <> 'REJECTED'
                AND rvt.organization_id = inv.organization_id(+)
                           AND rvt.locator_id = loc.physical_location_id(+)
                AND transaction_id NOT IN (
                       SELECT parent_transaction_id
                         FROM rcv_vrc_txs_v rvtd
                        WHERE rvt.item_id = rvtd.item_id
                          AND rvtd.transaction_type IN
                                      ('RETURN TO RECEIVING', 'RETURN TO VENDOR'))
                                      GROUP BY rvt.receipt_num , rvt.supplier ,
                    rvt.transaction_date , inv.segment1 ,
                    rvt.item_desc , hrov.NAME,v.standard_industry_clasS,po_headers.segment1,po_headers.creation_datE,
                    po_headers.creation_date_disp,inv.inventory_item_iD,loc.inventory_location_id,loc.organization_id,
                    rvt.locator_iD,rvt.currency_conversion_rate,po_lines.unit_price, rvt.transact_qtyis this correct ? i mean i have not included the bind parameters in the view ..moreover shoud this view be joined with all the columns in the from clause of the original query?
    kindly guide
    thanking in advance

Maybe you are looking for

  • Invalid path to word templates

    Hello, I am trying to export delivery note to word, but no way. It appears the following message: "Invalid path to word templates" I have checked under administration that the path set there is correct and the macros are with low security level. Than

  • "instant boot" to gray scale, then full use

    28Apr2015 iMac: 21.5, late 2013, OSX 10.9.5 I occasionally disconnect my iMac and store it or disconnect it when lightning is threatening (we live in Florida). Lately, the last couple of months, when setting up the mac again out of storage or disuse,

  • Error when opening FM9 - "cannot initialize its dictionaries"

    I just reinstalled FrameMaker 9 via the TCS 2 installation logged on as Administrator (with several days of Adobe Tech Support). I am on a Dell Latitude 630 Laptop running Windows 7 32-bit. The original problem with the TCS 2's RoboHelp has now been

  • Objective Setting processes help

    Hi When an employee forgets to complete his objective setting process ,then how he can re start the setting process ! What i thought was we can check the allow outside these dates while setting up objective setting process.But what happens for all th

  • SQL query to find out last login for each database

    Hi everybody, I have a view with following columns: DatabaseSid, lastLogin, firstLogin. I want to now the newest last_login date for every database. SID First Login Last Login e.g. Database1, 11.11.2011, 01.12.2011 Database1, 01.04.2012, 01.05.2012 D