Lag analytical function and controlling the offset

Can you help me on that? Small challenge. At least I gave up in half a day.
Data
ACCOUNT_NUMBER     BATCH_ID     TRANSACTION_DATE     TRANSACTION_TYPE     TRANSACTION_NUMBER     PARENT_TRANSACTION_NUMBER
124680     ZY000489     1/11/2011     62     377     NULL
124680     ZY000489     1/11/2011     1     378     NULL
124680     ZY000489     1/11/2011     1     379     NULL
124680     ZY000489     1/11/2011     1     380     NULL
124680     ZY000489     1/11/2011     62     381     NULL
124680     ZY000489     1/11/2011     1     381     NULL
124681     ZY000490     1/11/2011     350     4000     NULL
124681     ZY000490     1/11/2011     1     4001     NULL
124681     ZY000490     1/11/2011     1     4002     NULL
I want to identify parent Transaction Number for each row in above data.
The way to identify it is My parent transaction Id is
-     All child transaction have type as 1
-     One main transaction can have multiple line items.
-     Any transaction (type) can have an related child transaction (Transaction Type as 1)
-     Each logical group of transactions have same account number, batch id, transaction date and consecutive Transaction Number (like 377, 378, 379, 380 in above example)
The data should look like below once I identified parent transaction columns:
ACCOUNT_NUMBER     BATCH_ID     TRANSACTION_DATE     TRANSACTION_TYPE     TRANSACTION_NUMBER     PARENT_TRANSACTION_NUMBER
124680     ZY000489     1/11/2011     62     377     377
124680     ZY000489     1/11/2011     1     378     377
124680     ZY000489     1/11/2011     1     379     377
124680     ZY000489     1/11/2011     1     380     377
124680     ZY000489     1/11/2011     62     381     381
124680     ZY000489     1/11/2011     1     382     381
124681     ZY000490     1/11/2011     350     4000     4000
124681     ZY000490     1/11/2011     1     4001     4000
124681     ZY000490     1/11/2011     1     4002     4000
I tried using LAG Analytical function trying to lag dynamically with offset but had difficulties dynamically expanding the offset. Its an Control Break kind of functionality that i want to achieve in single SQL.
i Know we can do it using pl/sql construct but the challenge is to do it using single sql. Please help
Please let me know if you are able to do it in single SQL.
Thanks

rohitgoswami wrote:
Can you help me on that? Small challenge. At least I gave up in half a day.
Data
ACCOUNT_NUMBER     BATCH_ID     TRANSACTION_DATE     TRANSACTION_TYPE     TRANSACTION_NUMBER     PARENT_TRANSACTION_NUMBER
124680     ZY000489     1/11/2011     62     377     NULL
124680     ZY000489     1/11/2011     1     378     NULL
124680     ZY000489     1/11/2011     1     379     NULL
124680     ZY000489     1/11/2011     1     380     NULL
124680     ZY000489     1/11/2011     62     381     NULL
124680     ZY000489     1/11/2011     1     381     NULL
124681     ZY000490     1/11/2011     350     4000     NULL
124681     ZY000490     1/11/2011     1     4001     NULL
124681     ZY000490     1/11/2011     1     4002     NULL
I want to identify parent Transaction Number for each row in above data.
The way to identify it is My parent transaction Id is
-     All child transaction have type as 1
-     One main transaction can have multiple line items.
-     Any transaction (type) can have an related child transaction (Transaction Type as 1)
-     Each logical group of transactions have same account number, batch id, transaction date and consecutive Transaction Number (like 377, 378, 379, 380 in above example)
The data should look like below once I identified parent transaction columns:
ACCOUNT_NUMBER     BATCH_ID     TRANSACTION_DATE     TRANSACTION_TYPE     TRANSACTION_NUMBER     PARENT_TRANSACTION_NUMBER
124680     ZY000489     1/11/2011     62     377     377
124680     ZY000489     1/11/2011     1     378     377
124680     ZY000489     1/11/2011     1     379     377
124680     ZY000489     1/11/2011     1     380     377
124680     ZY000489     1/11/2011     62     381     381
124680     ZY000489     1/11/2011     1     382     381
124681     ZY000490     1/11/2011     350     4000     4000
124681     ZY000490     1/11/2011     1     4001     4000
124681     ZY000490     1/11/2011     1     4002     4000
I tried using LAG Analytical function trying to lag dynamically with offset but had difficulties dynamically expanding the offset. Its an Control Break kind of functionality that i want to achieve in single SQL.
i Know we can do it using pl/sql construct but the challenge is to do it using single sql. Please help
Please let me know if you are able to do it in single SQL.
ThanksCan probably pretty this up ... i just went for functional code for the moment.
TUBBY_TUBBZ?with
  2     data (acc_no, batch_id, trans_date, trans_type, trans_no) as
  3  (
  4    select 124680, 'ZY000489', to_date('1/11/2011', 'mm/dd/yyyy'), 62   , 377   from dual union all
  5    select 124680, 'ZY000489', to_date('1/11/2011', 'mm/dd/yyyy'), 1    , 378   from dual union all
  6    select 124680, 'ZY000489', to_date('1/11/2011', 'mm/dd/yyyy'), 1    , 379   from dual union all
  7    select 124680, 'ZY000489', to_date('1/11/2011', 'mm/dd/yyyy'), 1    , 380   from dual union all
  8    select 124680, 'ZY000489', to_date('1/11/2011', 'mm/dd/yyyy'), 62   , 381   from dual union all
  9    select 124680, 'ZY000489', to_date('1/11/2011', 'mm/dd/yyyy'), 1    , 382   from dual union all
10    select 124681, 'ZY000490', to_date('1/11/2011', 'mm/dd/yyyy'), 350  , 4000  from dual union all
11    select 124681, 'ZY000490', to_date('1/11/2011', 'mm/dd/yyyy'), 1    , 4001  from dual union all
12    select 124681, 'ZY000490', to_date('1/11/2011', 'mm/dd/yyyy'), 1    , 4002  from dual
13  )
14  select
15    acc_no,
16    batch_id,
17    trans_date,
18    trans_type,
19    trans_no,
20    case when trans_type != 1
21    then
22      trans_no
23    else
24      lag
25      (
26        case when trans_type = 1
27        then
28           null
29        else
30           trans_no
31        end
32        ignore nulls
33      ) over (partition by acc_no, batch_id, trans_date order by trans_no asc)
34    end as parent_trans_no
35  from data;
            ACC_NO BATCH_ID                 TRANS_DATE                         TRANS_TYPE           TRANS_NO    PARENT_TRANS_NO
            124680 ZY000489                 11-JAN-2011 12 00:00                       62                377                377
            124680 ZY000489                 11-JAN-2011 12 00:00                        1                378                377
            124680 ZY000489                 11-JAN-2011 12 00:00                        1                379                377
            124680 ZY000489                 11-JAN-2011 12 00:00                        1                380                377
            124680 ZY000489                 11-JAN-2011 12 00:00                       62                381                381
            124680 ZY000489                 11-JAN-2011 12 00:00                        1                382                381
            124681 ZY000490                 11-JAN-2011 12 00:00                      350               4000               4000
            124681 ZY000490                 11-JAN-2011 12 00:00                        1               4001               4000
            124681 ZY000490                 11-JAN-2011 12 00:00                        1               4002               4000
9 rows selected.
Elapsed: 00:00:00.01
TUBBY_TUBBZ?

Similar Messages

  • Switch the function and control keys

    Sounds like a stupid request but my life would be much simpler if my Lenova T540p keyboard had the function and control keys switched. I use the control key ALOT and having it to the far left hand lower corner would be awesome.
    Thank you.
    R

    Hey there Redrabbit,
    Try your BIOS. For me (Thinkpad T540p), it's in Config>Keyboard/Mouse>Switch FN and CTRL keys.

  • Can I swap the Function and Control keys?

    Is it possible to swap the Function and Control keys?

    With limitations; yes. Go to System Preferences and select Keyboards & Mouse and add your choices. Keep in mind that such chances will affect all well intended Apple commands and may end up driving you crazy!
    Regards,

  • How to customize function and control menus

    I am making the painful transition from 7.1 to 8.6. How can I customize the function and control menus, and have them always come up the same way on a right-click?
    Otherwise it takes several clicks to display the useful items, wasting time and effort.

    Dennis,
    It looks like this was never continued, but I have the same querstion. It seems like now when I right click up the menu I get what you see in the Not Very Useful Menu jpeg, and I have to clcik 3 more times to get to the More Useful Menu.
    Can this be changed by some option setting? I haven't found it and I wish I could.
    ~~~~~~~~~~~~~~~~~~~~
    Paul Johnson
    Renco Encoders, Inc
    Goleta, CA
    ~~~~~~~~~~~~~~~~~~~~
    Attachments:
    Not Vey Useful Menu.jpg ‏10 KB
    More Useful Menu.jpg ‏42 KB

  • Analytic function and aggregate function

    What are analytic function and aggregate function. What is difference between them?

    hi,
    Analytic Functions :----------
    Analytic functions compute an aggregate value based on a group of rows. They differ from aggregate functions in that they return multiple rows for each group. The group of rows is called a window and is defined by the analytic_clause. For each row, a sliding window of rows is defined. The window determines the range of rows used to perform the calculations for the current row. Window sizes can be based on either a physical number of rows or a logical interval such as time.
    Analytic functions are the last set of operations performed in a query except for the final ORDER BY clause. All joins and all WHERE, GROUP BY, and HAVING clauses are completed before the analytic functions are processed. Therefore, analytic functions can appear only in the select list or ORDER BY clause.
    Analytic functions are commonly used to compute cumulative, moving, centered, and reporting aggregates.
    Aggregate Functions :----------
    Aggregate functions return a single result row based on groups of rows, rather than on single rows. Aggregate functions can appear in select lists and in ORDER BY and HAVING clauses. They are commonly used with the GROUP BY clause in a SELECT statement, where Oracle Database divides the rows of a queried table or view into groups. In a query containing a GROUP BY clause, the elements of the select list can be aggregate functions, GROUP BY expressions, constants, or expressions involving one of these. Oracle applies the aggregate functions to each group of rows and returns a single result row for each group.
    If you omit the GROUP BY clause, then Oracle applies aggregate functions in the select list to all the rows in the queried table or view. You use aggregate functions in the HAVING clause to eliminate groups from the output based on the results of the aggregate functions, rather than on the values of the individual rows of the queried table or view.
    let me know if you are feeling any problem in understanding.
    thanks.
    Edited by: varun4dba on Jan 27, 2011 3:32 PM

  • Swapping Function and Control keys on a Lenovo Laptop

    Lenovo laptops reverse the usual positions of the Function and Control keys (see this photo). It seems like a minor problem, but it is very frustrating.
    How can I swap these keys? I have tried various xmodmap configurations (some based on the examples provided in the manual and some based on this eerily similar question), but nothing seems to work.
    Additional information
    Fn keycode: 151, Fn name: XF86WakeUp
    Left Control keycode: 37, Left Control name: Control_L
    Thanks in advance, best community ever.

    keenerd wrote:Ponder why you got a Thinkpad, then (optionally) swap them back.
    Free laptop from work. The hardware interface isn't great, but I'm not complaining. :-)
    Anyway, that worked beautifully. Thanks for the tip!

  • Apple AL Bluetooth Keyboard - Tab, Caps Lock, Function and Control keys just stopped working

    Hi All -
    All of a sudden I get on my baby, 27" iMac OSX 10.6 and the some keys on the bluetooth keyboard do not work. Specifially the Tab, Caps Lock, Function and Control keys. I'm fine with the caps lock gone (why is it there?) but the others are useful.
    I've searched all over for a solution but I haven't found one. Tried to upgrade the firmware which is fine, reset the PRAM done, checked the speech per apple support nadda.
    Please help.
    Thanks
    -M

    Hi
    Go to System preferances > Universal Access > Mouse or Mousie and trackpad > and turn your Mouse keys off.
    Then disconnect and reconnect your keyboard.
    Note that you don't open your mouse under hardware in System Preferances, this is for a whole different group of settings
    Hope This helps

  • Can i connect my iMac to a mac mini (wirelessly) and control the mac mini display on my TV?

    Can i connect my iMac to a mac mini (wirelessly) and control the mac mini display on my TV?

    Look up "screen sharing" in help
    You can control your mini (which I am assuming you are hooking to your TV) complete from your iMac.
    After you set up screen sharing, you can go to the finder, under the "go" menu choose "Connect to server" and then browse.  Choose your mac mini's name, and look for the "Screen Sharing" button.
    Choose Apple menu > System Preferences, and then click Sharing.
    Select the Screen Sharing checkbox.
    To specify who can share your screen, select one of the following:
    All users:
    Select this if you want to allow any user with a user account on your computer to share your screen.
    Only these users:
    Select this if you want to restrict screen sharing to specific users.Click Add at the bottom of the Users list and select a user from Users & Groups (accounts you have set up in Users & Groups preferences), Network Users (users on your network), or your Address Book. Or click New Person and enter a name and password to create a sharing account. Then select that user from the list, and then click Select.
    Click Computer Settings and set the following options:
    Anyone may request permission to control screen:
    Select this to allow anyone on your network to request to share your screen.
    VNC viewers may control screen with password:
    Select this and enter a password that VNC viewer applications can enter in order to control your screen.It’s recommended that you not set a password if you only share this computer’s screen using the built-in screen sharing viewer in Mac OS X.

  • Could I connect the lap top to TV and watch movies and control the lap top from a distance?

    could I connect the Apple lap top to my TV to watch movies and control the lap top from a distance just like the Window lap top???

    Check out Apple TV.  It is a wireless interface to your TV.  It may be the best $99 investment you can make for entertainment on your TV.  It simply requires a standard $10 HDMI cable, not supplied with the Apple TV unit.  Through Apple TV, with Mavericks, you can use the TV as a standard OS X monitor or for entertainment.  Also check out the Beamer software to stream videos to it from your Mac.
    Apple TV requires a Mid 2011 or newer MacBook Air with OS X Lion v10.7.5 or later.
    If your MBA is not new enough you can use the AirParrot application but the video quality is not as high as with a newer MBA.  It also streams from iOS devices.
    http://www.apple.com/appletv/
    http://www.apple.com/appletv/airplay/
    http://store.apple.com/us/ipod/ipod-accessories/apple-tv
    http://www.apple.com/osx/whats-new/features.html#displays
    http://www.amazon.com/AmazonBasics-High-Speed-HDMI-Cable-Meters/dp/B003L1ZYYM/re f=sr_1_1?ie=UTF8&qid=1385514116&sr=8-1&keywords=hdmi+cable
    AirPlay is available on all devices running iOS 4.3 or later. Some features require the latest software. Second-generation Apple TV or later required.
    AirPlay Mirroring is available with iPhone 4s or later; iPad 2 or later; iPad mini; iPod touch (5th generation); and iMac (Mid 2011 or newer), Mac mini (Mid 2011 or newer), MacBook Air (Mid 2011 or newer), MacBook Pro (Early 2011 or newer), and Mac Pro (Late 2013) with OS X Mountain Lion or later.

  • How to execute a function and return the result into a bind variable

    Hi,
    I am trying to calculate the sum of salaries of all persons with a particular JOB_ID using a function TOTAL_INCOME(v_job_id).
    create or replace function total_income
    +(v_job_id IN varchar2)+
    RETURN number IS
    v_total number(6);
    cursor get_sal is
    select salary from employees
    where job_id = v_job_id;
    BEGIN
    v_total := 0;
    for emp in get_sal
    loop
    v_total := v_total emp.salary;+
    end loop;
    dbms_output.put_line('Total salary of '||v_job_id||' is: '|| v_total);
    return v_total;
    END;
    Now I woud like to execute this function and assign the returned value into a bind variable test_sal
    variable test_sal number(6)
    SELECT total_income('AD_VP') into :test_sal FROM DUAL;
    dbms_output.put_line('Total Sal:'||:test_sal);
    This is returning the below errors:
    SELECT total_income('AD_VP') into :test_sal FROM DUAL
    *+
    Error at line 0
    ORA-01036: illegal variable name/number
    dbms_output.put_line('Total Sal:'||:test_sal);
    Error at line 3
    ORA-00900: invalid SQL statement
    Could someone help me what could be the problem?? Thanks for your time...

    Dear,
    If everything you will do will be done inside PL/SQL (stored procedure or stored function) then you don't have to care about bind variable.
    When using PL/SQL (static SQL) you will never encounter issues related to bind variables. PL/SQL itself takes care of your code and uses bind variables behind the scene.
    The only situation where you have to look carefully to the use of bind variables within PL/SQL is when you use Dynamic sql into stored procedures or functions.
    So, see in the light of the above comment, if you have to care about returning your function into a bind variable?
    Best regards
    Mohamed Houri

  • I just updated and I've lost my read it later function and all the articles I was saving. What happened?

    I just updated and I've lost my read it later function and all the articles I was saving. What happened? I'm very unhappy about this. Please help.

    Says its compatible with 4.0. <br />
    https://addons.mozilla.org/en-US/firefox/addon/read-it-later/

  • Hi I'm new to Mac. I have a macbook air and for some reason the top keys, ec, f1 etc etc are not functioning and emitt the non function noise when pressed. Also the volume keys don't adjust the volume. Have I done something to disable them?

    Hi I'm new to Mac. I have a macbook air and for some reason the top keys, ec, f1 etc etc are not functioning and emitt the non function noise when pressed. Also the volume keys don't adjust the volume. Have I done something to disable them?

    I don't have the same version of OS X here but try System Preferences>Keyboard. Is there an option similar to "Use the F1, etc, keys as standard function keys"?
    If so, and it has a checkmark, uncheck it & see if that does the trick.
    ~Lyssa

  • How do I show my keynote file on a dvd player and control the slides?

    how do I show my keynote file on a dvd player and control the slides with the skip or next chapter command on the dvd remote? when I export to quicktime, it changes slides on a timed basis. I want the chapter button on a dvd remote to act like a mouse click would.

    Hi Robert
    You have to export the individual slides from your Keynote presentation, and then import them into your DVD application.
    I use DVDStudioPro - it works fine this. I'm sure iDVD will be OK.Going via QT has never worked for me.
    Regards Robert
    G4(7 y.o)1.5GHz 1.25 GB Ram, 2x120GB intHD, orig AGP & Radeon 9200 PCI card   Mac OS X (10.4.8)   2monitors, CRT TV, FCP5.0.4, DVDSP4.1.1, STP1.1, Comp2.3, LT2.1, QT7.1.3

  • Using analytic function to get the right output.

    Dear all;
    I have the following sample date below
    create table temp_one
           id number(30),  
          placeid varchar2(400),
          issuedate  date,
          person varchar2(400),
          failures number(30),
          primary key(id)
    insert into temp_one values (1, 'NY', to_date('03/04/2011', 'MM/DD/YYYY'), 'John', 3);
    insert into temp_one values (2, 'NY', to_date('03/03/2011', 'MM/DD/YYYY'), 'Adam', 7);
    insert into temp_one values (3, 'Mexico', to_date('03/04/2011', 'MM/DD/YYYY'), 'Wendy', 3);
    insert into temp_one values (4, 'Mexico', to_date('03/14/2011', 'MM/DD/YYYY'), 'Gerry', 3);
    insert into temp_one values (5, 'Mexico', to_date('03/15/2011', 'MM/DD/YYYY'), 'Zick', 9);
    insert into temp_one values (6, 'London', to_date('03/16/2011', 'MM/DD/YYYY'), 'Mike', 8);this is output I desire
    placeid       issueperiod                               failures
    NY              02/28/2011 - 03/06/2011          10
    Mexico       02/28/2011 - 03/06/2011           3
    Mexico        03/14/2011 - 03/20/2011          12
    London        03/14/2011 - 03/20/2011          8All help is appreciated. I will post my query as soon as I am able to think of a good logic for this...

    hI,
    user13328581 wrote:
    ... Kindly note, I am still learning how to use analytic functions.That doesn't matter; analytic functions won't help in this problem. The aggregate SUM function is all you need.
    But what do you need to GROUP BY? What is each row of the result set going to represent? A placeid? Yes, each row will represent only one placedid, but it's going to be divided further. You want a separate row of output for every placeid and week, so you'll want to GROUP BY placeid and week. You don't want to GROUP BY the raw issuedate; that would put March 3 and March 4 into separate groups. And you don't want to GROUP BY failures; that would mean a row with 3 failures could never be in the same group as a row with 9 failures.
    This gets the output you posted from the sample data you posted:
    SELECT       placeid
    ,             TO_CHAR ( TRUNC (issuedate, 'IW')
                  , 'MM/DD/YYYY'
                ) || ' - '|| TO_CHAR ( TRUNC (issuedate, 'IW') + 6
                                             , 'MM/DD/YYY'
                               )     AS issueperiod
    ,       SUM (failures)                  AS sumfailures
    FROM        temp_one
    GROUP BY  placeid
    ,            TRUNC (issuedate, 'IW')
    ;You could use a sub-query to compute TRUNC (issuedate, 'IW') once. The code would be about as complicated, efficiency probably won't improve noticeably, and the the results would be the same.

  • OLAP Expression Analytical Functions and NA Values

    Hello,
    I am trying to use the SUM and MAX functions over a hierarchy where there are potentially NA values. I believe in OLAP DML, the natural behavior is to skip these values. Can a skip be accomplished with either the SUM or MAX OLAP Expression Syntax functions?
    Cheers!

    Pre-requisites:
    ===============
    Time dimension with level=DAY.... i have restricted data to 1 month approx.. 20100101 to 20100201 (32 days).
    Measure of interest - a (say)
    Time Dimension attribute which indicates WEEKDAY.... if you have END_DATE attribute with date datatype so we can extract the DAY (MON/TUE/WED/...) from it and decipher wkday/wkend status for DAY.
    Sort time as per END_DATE ..
    Take care of other dimensions during testing... restrict all other dimensions of cube to single value. Final formula would be independent of other dimensions but this helps development/testing.
    Step 1:
    ======
    "Firm up the required design in olap dml
    "rpr down time
    " w 10 heading 't long' time_long_description
    " w 10 heading 't end date' time_end_date
    " w 20 heading 'Day Type' convert(time_end_date text 'DY')
    " a
    NOTE: version 1 of moving total
    " heading 'moving minus 2 all' movingtotal(a, -2, 0, 1, time status)
    " w 20 heading 'Day Type' convert(time_end_date text 'DY')
    " heading 'a wkday' if convert(time_end_date text 'DY') ne 'SAT' and convert(time_end_date text 'DY') ne 'SUN' then a else na
    NOTE: version 2 of moving total
    " heading 'moving minus 2 wkday' movingtotal(a, -2, 0, 1, time convert(time_end_date text 'DY') ne 'SAT' and convert(time_end_date text 'DY') ne 'SUN')
    " w 20 heading 'Day Type' convert(time_end_date text 'DY')
    " heading 'a wkday non-na' if convert(time_end_date text 'DY') ne 'SAT' and convert(time_end_date text 'DY') ne 'SUN' and a ne na then a else na
    NOTE: version 3 of moving total
    " heading 'moving minus 2 wkday non-na' movingtotal(a, -2, 0, 1, time convert(time_end_date text 'DY') ne 'SAT' and convert(time_end_date text 'DY') ne 'SUN' and a ne na)
    OLAP DML Command:
    rpr down time w 10 heading 't long' time_long_description w 10 heading 't end date' time_end_date w 20 heading 'Day Type' convert(time_end_date text 'DY') a heading 'moving minus 2 all' movingtotal(a, -2, 0, 1, time status) w 20 heading 'Day Type' convert(time_end_date text 'DY') heading 'a wkday' if convert(time_end_date text 'DY') ne 'SAT' and convert(time_end_date text 'DY') ne 'SUN' then a else na heading 'moving minus 2 wkday' movingtotal(a, -2, 0, 1, time convert(time_end_date text 'DY') ne 'SAT' and convert(time_end_date text 'DY') ne 'SUN') w 20 heading 'Day Type' convert(time_end_date text 'DY') heading 'a wkday non-na' if convert(time_end_date text 'DY') ne 'SAT' and convert(time_end_date text 'DY') ne 'SUN' and a ne na then a else na heading 'moving minus 2 wkday non-na' movingtotal(a, -2, 0, 1, time convert(time_end_date text 'DY') ne 'SAT' and convert(time_end_date text 'DY') ne 'SUN' and a ne na)
    Step 2:
    ======
    "Define additional measure to contain the required/desired formula implementing the business requirements (version 3 above)
    " create formula AF1 which points to last column... i.e. OLAP_DML_EXPRESSION
    dfn af1 formula movingtotal(a, -2, 0, 1, time convert(time_end_date text 'DY') ne 'SAT' and convert(time_end_date text 'DY') ne 'SUN' and a ne na)
    "NOTE: Do this via AWM using calculated member with template type = OLAP_DML_EXPRESSION so that the cube view for cube contains a column for measure AF1
    OLAP DML Command:
    rpr down time w 10 heading 't long' time_long_description w 10 heading 't end date' time_end_date w 20 heading 'Day Type' convert(time_end_date text 'DY') a heading 'a wkday non-na' if convert(time_end_date text 'DY') ne 'SAT' and convert(time_end_date text 'DY') ne 'SUN' and a ne na then a else na heading 'moving minus 2 wkday non-na (AF1)' af1
    ->
    Step 3:
    =======
    Extend Oracle OLAP with regular SQL functionality like SQL ANALYTICAL functions to fill up the gaps for intermediate week days like DAY_20100104 (TUE), DAY_20100105 (WED) etc.
    Use: SQL Analytical Function LAST_VALUE() in query.. i.e. in report or query.. dont use AF1 but use LAST_VALUE(af1).... as below pseudo-code:
    LAST_VALUE(cube_view.af1) over (partition by <product, organization, ... non-time dimensions> order by <DAY_KEY_Col> range unbounded preceeding and current row)
    HTH
    Shankar

Maybe you are looking for