rolliing backword window. How to calculate and op like this

I have date as below
with abc as (select 1 userid, 11 clo_id, to_date('05/01/2009', 'dd/mm/yyyy') c_date, 216 ilo_id, to_date('06/01/2009', 'dd/mm/yyyy') i_date from dual union all
             select 1 userid, 11 clo_id, to_date('05/01/2009', 'dd/mm/yyyy') c_date, 215 ilo_id, to_date('05/01/2009', 'dd/mm/yyyy') i_date from dual union all
             select 1 userid, 11 clo_id, to_date('05/01/2009', 'dd/mm/yyyy') c_date, 214 ilo_id, to_date('04/01/2009', 'dd/mm/yyyy') i_date from dual union all
             select 1 userid, 11 clo_id, to_date('05/01/2009', 'dd/mm/yyyy') c_date, 213 ilo_id, to_date('04/01/2009', 'dd/mm/yyyy') i_date from dual union all
             select 1 userid, 11 clo_id, to_date('05/01/2009', 'dd/mm/yyyy') c_date, 212 ilo_id, to_date('03/01/2009', 'dd/mm/yyyy') i_date from dual union all
             select 1 userid, 11 clo_id, to_date('05/01/2009', 'dd/mm/yyyy') c_date, 211 ilo_id, to_date('02/01/2009', 'dd/mm/yyyy') i_date from dual)
select *
from   abc



USERID     CLO_ID      C_DATE                       ILO_ID  I_DATE            

         1         11 05/01/2009 00:00:00        216 06/01/2009 00:00:00 
         1         11 05/01/2009 00:00:00        215 05/01/2009 00:00:00 
         1         11 05/01/2009 00:00:00        214 04/01/2009 00:00:00 
         1         11 05/01/2009 00:00:00        213 04/01/2009 00:00:00 
         1         11 05/01/2009 00:00:00        212 03/01/2009 00:00:00 
         1         11 05/01/2009 00:00:00        211 02/01/2009 00:00:00 


Now i want to calculate rolling backword frequency of each ilo id and output should come like as based Frequency winodw 

e.g. if frequency window is 2 then 


USERID   CLO_ID C_DATE                     ILO_ID  I_DATE                        FREQUENCY
         1         11 05/01/2009 00:00:00        216 06/01/2009 00:00:00          2
         1         11 05/01/2009 00:00:00        215 05/01/2009 00:00:00          3
         1         11 05/01/2009 00:00:00        214 04/01/2009 00:00:00          3
         1         11 05/01/2009 00:00:00        213 04/01/2009 00:00:00          2
         1         11 05/01/2009 00:00:00        212 03/01/2009 00:00:00          2
         1         11 05/01/2009 00:00:00        211 02/01/2009 00:00:00          1

1. For each ILO ID, go back number od days given as Frequency window (in our case its 2)
2. calculate the number of ilo_id in that range
3. number of ilo_id is the frequency of that ilo_id
How can I achieve this.

Published by: Kuldeep2 on September 29, 2010 02:30

Published by: Kuldeep2 on September 29, 2010 02:33
with abc as (select 1 userid, 11 clo_id, to_date('05/01/2009', 'dd/mm/yyyy') c_date, 216 ilo_id, to_date('06/01/2009', 'dd/mm/yyyy') i_date from dual union all
select 1 userid, 11 clo_id, to_date('05/01/2009', 'dd/mm/yyyy') c_date, 215 ilo_id, to_date('05/01/2009', 'dd/mm/yyyy') i_date from dual union all
select 1 userid, 11 clo_id, to_date('05/01/2009', 'dd/mm/yyyy') c_date, 214 ilo_id, to_date('04/01/2009', 'dd/mm/yyyy') i_date from dual union all
select 1 userid, 11 clo_id, to_date('05/01/2009', 'dd/mm/yyyy') c_date, 213 ilo_id, to_date('04/01/2009', 'dd/mm/yyyy') i_date from dual union all
select 1 userid, 11 clo_id, to_date('05/01/2009', 'dd/mm/yyyy') c_date, 212 ilo_id, to_date('03/01/2009', 'dd/mm/yyyy') i_date from dual union all
select 1 userid, 11 clo_id, to_date('05/01/2009', 'dd/mm/yyyy') c_date, 211 ilo_id, to_date('02/01/2009', 'dd/mm/yyyy') i_date from dual)
select abc.*,
       (
       select count(distinct ilo_id)
       from abc x
       where x.i_date between abc.i_date - ( :frequency_window  -  1 ) and abc.i_date
       and  ( (x.i_date=abc.i_date and x.ilo_id<=abc.ilo_id) or (x.i_date

My last try. I changed the condition for counting again (see code).

Tags: Database

Similar Questions

  • There are invisible files of &#62; 100 GB C:\Users\B folder... \AppData\Local\Microsoft\Windows: how to remove and release this space?

    There are invisible files of > 100 GB C:\Users\B folder... \AppData\Local\Microsoft\Windows: how to remove and release this space?

    Explore it has been configured to show hidden files. Files can come from files continuously from the satellite receiver via WiFi with windows media player.
    Windows 7 premium 64-bit, protection against viruses,... with microsoft.

    To study disk space, use download and install Treesize (freeware).
    https://www.Jam-software.de/customers/downloadTrial.php?ARTICLE_NO=80&language=en&PHPSESSID=6odgempt76un9q9nkj7luf5be0

    Information about Treesize

    http://www.Jam-software.com/treesize_free/

    When you open Treesize scan select in the Menu and you will see a list of drives. Click on C and it will generate a list of files. Display names and 6 larger files sizes and the total at the top of the list.

  • I SAVE ALL MY DATA TO AN EXTERNAL HARD DRIVE MDL WD16001032 AND LOOKS LIKE THIS INS DEVICE IS NOT COMPATIBLE WITH WINDOWS 7... WHAT CAN I DO?

    I SAVE ALL MY DATA TO AN EXTERNAL HARD DRIVE MDL WD16001032 AND LOOKS LIKE THIS INS DEVICE IS NOT COMPATIBLE WITH WINDOWS 7... WHAT CAN I DO?

    I SAVE ALL MY DATA TO AN EXTERNAL HARD DRIVE MDL WD16001032 AND LOOKS LIKE THIS INS DEVICE IS NOT COMPATIBLE WITH WINDOWS 7... WHAT CAN I DO?

    I don't understand. What makes you think the reader 'is not compatible' with Windows 7? Windows (or any other OS besides) sees no external hard drives as "compatible" or not...

    Now if you have a PROPRIETARY disk, then that is a different case. If you find my answer helpful, please click the button "Vote as helpful"! Thank you! My Blog

  • How to make a screen like this on Blackberry

    Sorry for the title but I don't know how to summarize the issue.

    I need to make a screen like this:

    As you can see, it shows these 'boxes' with elements of user interface inside each of them.

    Each 'case' is placed inside something like some sort of table cells.

    I thought it would be a good idea to represent the 'boxes' as individual screens inside a TableLayoutManager with vertical scrolling, but I don't even know if it's reliable.

    Please someone tell me how to do something like that on the BlackBerry because I have no idea where to start.

    I use JRE BlackBerry 4.5.0

    Thanks in advance!

    I would not use TableLayoutManager for that.  In fact, I would write my own Manager specific to each "Box" that you see and then just add the number of these 'boxes' that I needed.

    But since you are new (and welcome to the forums!), I think that you can get pretty close to what you want by using standard controls.

    You use a screen - and setTitle allows to set the title of the screen.  In your setTitle you would define a LabelField - and before you set, you will specify the size of the font you need.  For font color, you will need to override the paint.  In object, you just set the color of your choice

    .setColor (.)

    and then call the super.paint.

    The tips are:

    (1) setTitle is that at a certain level of the OS, it changes to be white to be black, then you will need to override paintBackground() to set the background on the color you want.

    (2) you must specify thje USE_ALL_WIDTH style for this LabelField.

    This kind of thing (change the color and the background color of a LabelField) is fairly widespread, the forum for more search tips.

    On this screen you will add each box.  Each box will be a VerticalFieldManager - you can use setMargin (...) to space out these as you wish.   Call everyone your 'BoxManager.

    Each VerticalFieldManager you will have been given the title bar.  Title bar is an another LabelField as you added under the title of the screen.  Once more you will crush object and maybe paintBackground() to get the colors you want.  Again use USE_ALL_WIDTH.  But to get the Bitmap image, you must expand the LabelField class and provide a setBitmap for this class.  Then in painting, that you have overridden it to set the color, you will also need to use

    .drawBitmap, to paint the image on the right side.

    This, after the call to super.paint ().

    The footer bar is very similar, but this time you will use the DrawStyle.FIELD_RIGHT for the labelField painted himself on the right.  It is in the constructor.

    Finally the trickiest part, the lines and the button.  Leave this for last...

    The simplest option is to add to your BoxManager and HorizonalFieldManager.  Then add a button and a RichTextField (not a LabelField) to that.  This will give you the button first.  Not what you want, but until you have worked a little bit more, are the best option.  You can us back later to get the button on the right side.

    OK, enough, do this step at a time and ask questions about each control separately that you have problems with.

    Good luck.

    If you want to create your own search BoxManager, see

    http://supportforums.BlackBerry.com/T5/Java-development/how-to-extend-Manager/Ta-p/446749

    and

    http://supportforums.BlackBerry.com/T5/Java-development/create-a-custom-layout-manager-for-a-screen/...

  • How can I create something like this?

    Hello

    I am fairly new to dream and work to build my Web site.

    I have a portfolio of work that I would be able to sort and display like that...

    David Gauntlett. Portfolio

    Could someone point me to a tutorial or begin to describe how I could achieve.

    Thank you Sarah.

    Hi Sarah,.

    You would not be able to realize exactly what only Muse. You can achieve something similar by using the Panel tabs widget and add each category in a different tab.

  • How would I do something like this border effect?

    I was wondering how to do this? Anyone know?photo.jpg

    Do the trace form like this

    Rasterize the shape and apply the Gaussian blur

    Make your choice and add a layer mask

  • How can I configure something like this?

    Grid.JPG

    I took this screenshot from InDesign. Several months ago a friend created this grid for me. I want to use it to make fake stamps. However, I notice that some of the points are overlapped in places (you may need to zoom to see this).

    I wonder if someone can tell me how I can set up a grid like this on my own. I tried and not had much luck. I want to be able to put images in each 'cell' (you will see boxes that I put there already). Is there an easy way to do this? Do not look exactly like what did my friend, but I would like something similar. Please, can someone point me in the right direction?

    Thank you!

    ladyinblack1964 wrote:

    However, I do understand the step and repeat part. While your screenshot is out with no gutter between the boxes, mine did. I do not understand orders from offset box.

    My boxes are 1.25 "x 1.75". I want to only six columns in each row. Not sure how many lines I want yet.

    What I am doing wrong? Thanks v. much.

    compensation must be set to the dimensions of the frames, no room between, you do not want any space, if you use 1.25 for the horizontal shift (and the number of copies to 5 or the number of rows to 6, depending on wheter you selected created as a game grid) and the value of vertical to 1.75 and the number to be determined. If you do not select Create as a grid, the vertical offset set to 0 for the first step, then select the entire row, repeat step and repeat, put the horizontal offset to 0 and make the vertical offset to 1.75 times th number of lines, less one, you need in the field copies.

  • How to create a form like this?

    I want to create something like this:

    navbar.png

    I have now the idea of creating images from scratch, I hope that you can help me.

    Something like that could be done in Photoshop using tools such as the pen tool. Since it is symmetric, essentially, you would create a half of the shape can duplicate, flip, and merge all as a single form. You would create while all the effects on the shape later as shadow and texture.

    But the pen tool can be difficult for some users to understand. Adobe Illustrator may be your best bet in this case.

  • How to make a site like this on adobe muse? the effect of sliding page...

    Something like this site... http://www.razvangarofeanu.com/#the-g is this possible on muse adobe? Thank you!

    You can design probably the horizontal content, but with that page, you will need to link this anchor specific to another separately created page as as in case you use a single provision for all the contents of the page then you can not keep a different dimension to the same section of the page as a landscape and another section vertical. So it would create the content with content horizontal and vertical content and then link them with anchor points.

    I recommend you to try this out and check.

    Thank you

    Sanjit

  • Can someone help me understand how the code should look like this?

    I keep looking for forums and I can't figure out if I need an instance name, a frame name, convert to symbol, graphics or video clip. All that I want is the images I have to move and stop as this graph on this website. If anyone can help to provide the code, it would be greatly appreciated!

    Best,

    Brett

    http://byluisvenegas.com/zines/ey-magateen/ey-magateen-5/

    this.addEventListener (MouseEvent.MOUSE_OVER, stopF);

    this.addEventListener (MouseEvent.MOUSE_OUT, playF);

    function stopF(e:MouseEvent):void {}

    This.Stop ();

    }

    function playF(e:MouseEvent):void {}

    This.Play ();

    }

  • I couldn't open Firefox account for said synch.it work... and waiting like this for always...

    no way to send data to Mozilla, said work and wait like that. ex: I tried to upload a picture on the screen for this below.but, could not download.

    Hi veejdoo, unfortunately this is currently a known issue in firefox 50 when you set the browser to run in permanent private browsing mode ("remember never history ' in the options > confidentiality Panel). Firefox developers are working to get this fixed in versions to come yet... Confidentiality, and-not-track browsing history settings

  • How can I make Windows 7 Explorer look and work like it does in XP?

    Hello...

    The GUI in the Win7 Explorer is a waste of screen real estate when it comes to want to work with files.

    I don't want the icons or all divisions of the way in which it uses by default, and I don't want to have only a small space to expand the + for each folder tree. I would like to have the Explorer Win 7 have the same look and feel as in windows XP. Call 'classic' view of windows Explorer.

    How can I do this?  I tried but could not get that look in Win7.

    If this is not possible, then what was the reason for the deletion of this presentation?  What Microsoft problem trying to resolve to change this?

    Thank you for your help.

    See you soon!

    nor do I want to have only a small space to expand the + for each folder tree.

    On the right, and then drag the column separator...

    Do organize putting on the page and choose your preferred format it...

    If you find my answer helpful, please click the button "Vote as helpful"! Thank you!
    My Blog

  • Windows 7-windows-how mail edit and resend a sent email

    How can I edit and resend an email I sent.  I want to change a date in the email and do not want to search and seize all the people and the message has been sent to contact groups.  I could easily do in outlook, eudora or thunderbird - but can't figure out in windows mail - help? » ?

    You run Windows Mail in Win7, not Windows Live Mail?

    Open the message in sent items and click Next. Remove the Fw: in the subject. Remove the original addresses. Make the changes you need to do. Press send.

    Bruce Hagen ~ MS - MVP [Mail]

  • 8.1 upgrade of Windows 8 Windows - how to find and remove the incomplete installation file

    I went to the Windows 8 8.1 Windows installation option. While it has been downloaded the file, I turned off by computer error. The file I have is not complete. I would like to delete this file and try again. How/where can I find this file to delete? When I try to access the Windows store to download the file again, it starts the installation process (which assumes that the file I have is over). I think that in the Manager of tasks in desktop view, that I managed to stop the process.

    Download uses a technology called BITS (Background Intelligent Transfer Service), as well as the missing pieces of the file will be downloaded when they are required.  So just let it run, it will take care of itself.

  • I suddenly have a voice over from Firefox - and one thing he says is "Firefox new window ' - how can I get rid of this voice?

    I now sound like welcome me to MAC - and often telling me that Firefox has new window - close button said OCC. Also announced many other things.

    You turn on VoiceOver Accessibility feature (System-> Speech Preferences; (fn) Cmd - F5)

Maybe you are looking for

  • Satellite A30: Canoe start Recovery CD - cannot read disc information

    My a30 is about six years old.About two years ago, I used the recovery disks to format and reinstall windows xpI'm trying to do the same thing again now, but a window appears saying "can't read disc information.What could have happened to cause the a

  • Windows10 car does not start after cloning of SSD (mid-2010)

    Hi all. In my mid-2010 mac pro, I have a windows disc 10 (upgraded to 8.1 windows) in the Bay 3. I want to update to SSDS. So, I bought one, I cloned the drive with winclone app pro (v.5.4) but the new drive is not bootable. When I choose to boot fro

  • Try to install an update to Itunes

    My Dell computer manages 64-bit of Windows Vista Service Pk 2.  Several times I received messages from upgrade to Itunes 9.03.  When I try to do, software downloads and automatically starts to install it and fails.  Message saying "an error has occur

  • Impossible to validate my copy purchased from Adobe Lightroom serial number

    I bought Adobe Lightroom and just downloaded on my Mac. When I want to record my serial number, it says that it cannot be validated.What is frustrating is that with this message they heading me into this forum page ("no phone support is available for

  • A request for a better management of meta data

    Adobe can make good use of metadata, but I think that improvements could be made. Here is a link to a short video with some suggestions.Premiere Pro meta data functionality QUERIES - YouTube