WOuld Analytic Windowing Clause help solve this?

I've been using some basic analytic functions for a little while now. Trying to do something that I don't know if it's syntactically legal...or if maybe I'm just approaching it the wrong way.
I have a situation like this...
with t1 as
(SELECT 1 AS id , 1 AS value_1, 'Y' valid_1 , 12 AS value_2 , 'N' valid_2 , 38 AS value_3 , 'N' valid_3 , 45 AS value_4 , 'Y' valid_4 FROM dual
UNION ALL
SELECT 2 AS id , 3 AS value_1, 'N' valid_1 , 7 AS value_2 , 'Y' valid_2 , 13 AS value_3 , 'Y' valid_3 , 19 AS value_4 , 'N' valid_4 FROM dual)
select
  id,
  pivot,
  pivoted_value,
  pivoted_valid,
  max(pivoted_value) over (partition by id
                           order by pivot
                          ) as analytic_expr
from (
select
  t1.id,
  t2.pivot,
  case t2.pivot
    when 1 then t1.value_1
    when 2 then t1.value_2
    when 3 then t1.value_3
    when 4 then t1.value_4
  end as pivoted_value,
  case t2.pivot
    when 1 then t1.valid_1
    when 2 then t1.valid_2
    when 3 then t1.valid_3
    when 4 then t1.valid_4
  end as pivoted_valid
from t1, (select rownum pivot from dual connect by rownum < 5) t2
        ID      PIVOT PIVOTED_VALUE P ANALYTIC_EXPR
         1          1             1 Y             1
         1          2            12 N            12
         1          3            38 N            38
         1          4            45 Y            45
         2          1             3 N             3
         2          2             7 Y             7
         2          3            13 Y            13
         2          4            19 N            19...which get's me close to what I'm looking to do. But rather than having a running max, I'd need it to increment only when the value is "valid". So for row 2 above, the value of analytic_expr should stay 1 for rows 2,3. Row 5 should be null (or some other defautable value), and the last row should stay at 13.
Does <where pivot_value = 'Y'> translate into some useable windowing clause, or so I have to do something a little less elegant?

Mentioning that values 1-4 are always increasing would probably made my statement sensible.
If pivoted_valid(X) = 'Y' (column name name got copped to "P" for some reason)
Then pivoted_value(x) ....which will also be the current max if they're ordered in
Else the max(pivoted_value(<x))
This is how I would want the results to look...
ID   PIVOT    VAL   VALID    CURRENT_MAX_VAL
1     1     1     Y     1
1     2     12     N     1    --since not valid, no change to prior
1     3     38     N     1     --since not valid, no change to prior
1     4     45     Y     45
2     1     3     N     nulll    --since not valid and no prior row
2     2     7     Y     7
2     3     13     Y     13
2     4     19     N     13   --since not valid, no change to priorI know I could probably do this with a CASE/LAG combo of some sort. I was just wondering how fancy a person could get with windowing.

Similar Messages

  • I've installed CS6 and web Premium on a Mac running 10.9.5, and Dreamweaver,Flash and Illustrator wont launch.  All other components work normally.  In Activity monitor it says Adobe switchboard failed to respond.  Can anyone help solve this issue?

    I've installed CS6 and web Premium on a Mac running 10.9.5, and Dreamweaver,Flash and Illustrator wont launch.  All other components work normally.  In Activity monitor it says Adobe switchboard failed to respond.  Can anyone help solve this issue?

    Release: 4/25/2012
    http://support.amd.com/us/gpudownload/windows/Pages/radeonmob_win7-64.aspx

  • How do I copy files onto a hard drive (device) from Mac 2 7 pc. I'm able to transfer files from device but cannot transfer files to device. Anyone had same problem or can help solve this problem? Help pls

    how do I copy files onto a hard drive (device) from Mac 2 7 pc. I'm able to transfer files from device but cannot transfer files to device. Anyone had same problem or can help solve this problem? Help pls

    Welcome to Apple Support Communities
    When you try to copy data to the external drive, what happens? If you don't see any error, the external drive is formatted in NTFS, and OS X can't write in it.
    To be able to write on this external drive, you have to use an app like Paragon NTFS. Another solution would be to format the external drive in FAT32 or exFAT with Disk Utility > http://pondini.org/OSX/DU1.html Make sure you copied all the files of the external disk to the internal disk before doing it

  • My macbook Pro 13" 2013 has a mouse problem, its not moving naturally, and keeps on moving around like its dancing. Please help solve this!!

    My macbook Pro 13" 2013 has a mouse problem, its not moving naturally, and keeps on moving around like its dancing. Please help solve this!!

    Go step by step and test.
    1. Restart
    2. Shut down the computer.
        Clean the trackpad with moist not wet microfiber cloth.
        System Preferences > Point & Click
        Try turning off three finger dragging and then turning it on after  testing.
    3. Is there any Bluetooth device nearby with failing batteries? If so, replace the batteries.
      4. Reset PRAM:   http://support.apple.com/kb/PH14222
    5. Reset SMC.     http://support.apple.com/kb/HT3964
        Choose the method for:
        "Resetting SMC on portables with a battery you should not remove on your own".
    6. Close all windows and quit all applications.
        Click the Spotlight -the magnifying glass icon- in the menu bar. Enter Disk utility in the box.
        Select Disk Utility from the drop down. When the Disk utility window opens up,
        select  Macintosh HD, then First Aid.
        Click Repair Disk Permissions button.
        Ignore the  time remaining estimate.
        Last 1 minute may take longer.

  • I recently updated my computer to 10.6 and now I can't get my printer MX340 (canon ) to work. I have installed the new drivers both from Canon's website and from an earlier post directly from apples website. I would surely appreciate some help with this.

    I recently updated my computer to 10.6 and now I can't get my printer MX340 (canon ) to work. I have installed the new drivers both from Canon's website and from an earlier post directly from apples website. I would surely appreciate some help with this.

    Try what Terence Devlin posted in this topic:
    Terence Devlin
    Apr 14, 2015 11:21 AM
    Re: Is Iphoto gone ? i want it back!
    in response to Johannes666
    Recommended
    Go to the App Store and check out the Purchases List. If iPhoto is there then it will be v9.6.1
    If it is there, then drag your existing iPhoto app (not the library, just the app) to the trash
    Install the App from the App Store.
    Sometimes iPhoto is not visible on the Purchases List. it may be hidden. See this article for details on how to unhide it.
    http://support.apple.com/kb/HT4928
    One question often asked: Will I lose my Photos if I reinstall?
    iPhoto the application and the iPhoto Library are two different parts of the iPhoto programme. So, reinstalling the app should not affect the Library. BUT you should always have a back up before doing this kind of work. Always.

  • HT4101 Connecting my lightning to sd card reader accessoire THE iPad air Lets know' this accessory is not. supported by this iPad' could Someren help solving this issue?

    Connecting my lightning to sd card reader accessoire THE iPad air Lets know' this accessory is not. supported by this iPad' could Someren help solving this issue?

    Thanks for the advice. Unfortunately it didn't work. Have tried both kinds of restore. First restoring from backup and second as a new device (twice). Still get the same "Accessory not supported" message. Thank goodness I can use the old 30 pin SD reader with the lightning adaptor for my up-coming trip. I tried it again and it worked again. BUT I hate having a piece of Apple equipment that doesn't work.

  • My ipad turns off randomly and doesnt turn back on and wont restore with itunes and i tried holding the power and home button down and i see a faint apple logo than it disappears and still does not operate please help solve this issue

    My ipad turns off randomly and doesnt turn back on and wont restore with itunes and i tried holding the power and home button down and i see a faint apple logo than it disappears and still does not operate please help solve this issue

    i have the same problem...my ipod is 4th generation?uggghhhhh

  • I made a movie on iMovie and went to burn to DVD and of course I could not...contacted Apple and they said to download an app to help solve this problem...i did..so I could finally burn a DVD, but it will not play on my DVD player...HELP!!!

    I made a movie on IMovie and went to burn it to a DVD ...I could not do this so I contacted Apple..they had me download an App and then I could make a DVD...but it will not play on my DVD player...does anyone know how I can solve this problem.. I purchased this to make DVD's and now I can not do that!!

    This is a known issue.  It really comes down to two key factors - what type of DVD are you burning to + what type of DVD player you have.
    This article will help.  It's lengthy and can be technical in some parts but should shed some light on your problem.
    http://www.media.utah.edu/dvdworkshop/pdf/DVDCompatTest.pdf

  • PLEASE HELP SOLVING THIS PROBLEM

    Our buissness will fail if we could not solve this problem.
    we have 1720 cisco router that has 2 WIC one is the backup to the other.we need to chick if the communication through one WIC to a specific router connected to it failed the other WIC could keep the route to the same router .how could we do this(what is the configuration?)and what is the suitable IOS that we could use?
    Please help.

    Abbas,
    You define two routes in the router with different Administrative distance.
    Define ip routes
    ip route 0.0.0.0 0.0.0.0 serial0
    ip route 0.0.0.0 0.0.0.0 serial1 170(Administrative distance is 170)
    The route with least administrative distance is prefered if you have two similar routes in the routing table.
    Hope this solves ur issue.

  • Services disappearing? Need help solving this.

    Over the years I have created many Services (using automator and applescript), so that when you right click a folder or file you have the option to click on the service.
    However In the recent weeks it has come up where sometimes the Service field disappears. How I get them back is logging out and then logging back in.
    Does this mean I have some virus or something? Is there a way to handle this?
    Here is what is supposed to come up:
    Here is what happens sometimes:
    Thanks guys

    How often do you need to do this? I think that a script which would work properly may be more work than is worth the time.
    I'm sure something like this could be done, but the real problem would be what would the next group of lines that you run the script on look like? Would a script that works for this circumstance work properly for another shape?
    Here's some parameters to think about:
    How do you determine which line segments (or endpoints) in the document need to be connected? All points in the document, or will you be working with a selection?
    Once you determine the points (eliminating all that are already connected), how do you want them connected, and which point do you start with? Connect to the closest available point would seem what you want, but depending on how you determine which point to start with could give you different results.
    You might want to loop through all eligible points, and save the distance to every other point into an array. Then, loop through connecting the 2 closest available points until you've connected every point.

  • Need help solving this tricky connect paths problem!

    I need to convert a bunch of separate paths  in particular way so they create one single continuos path as shown in the attached PNG file.
    It has me stumped. Does anyone know of a way to do this via scripting?

    How often do you need to do this? I think that a script which would work properly may be more work than is worth the time.
    I'm sure something like this could be done, but the real problem would be what would the next group of lines that you run the script on look like? Would a script that works for this circumstance work properly for another shape?
    Here's some parameters to think about:
    How do you determine which line segments (or endpoints) in the document need to be connected? All points in the document, or will you be working with a selection?
    Once you determine the points (eliminating all that are already connected), how do you want them connected, and which point do you start with? Connect to the closest available point would seem what you want, but depending on how you determine which point to start with could give you different results.
    You might want to loop through all eligible points, and save the distance to every other point into an array. Then, loop through connecting the 2 closest available points until you've connected every point.

  • Since upgrading to firefox4.0, my NVIDIA kernel mode driver frequently not responding, turning monitor black, then successfully recovered. The Firefox browser would then crash afterwards. Please help solve this very annoying problem.

    as above.

    I have the same problem. I just upgraded to Win 7, no problems. Then I upgraded to FF 4.0, and I kept getting Nvidia Video Card crashes. I always undo my last computer change/install when something like this happens, so I immediately uninstalled 4.0, and went back to my older version of Firefox. No problems ever since.

  • Help solving this Bugcheck! Please and thanks!

    Hey guys, 
    My computer has been crashing to the Windows 8.1 blue screen a lot lately. 4 times today!! making hard to get any work done. I had an issue with this in February but it seemed to go away on its own (maybe
    with driver updates?). 
    But this last two weeks have been too crazy with the crashes so I thought I would try and solve it today. I looked at the stability action center and found this error (along with others):
    The computer has rebooted from a bugcheck.  The bugcheck was: 0x00000124 (0x0000000000000000, 0xffffe001a058d028, 0x00000000bf800000, 0x0000000000000124). A dump was saved in: C:\WINDOWS\MEMORY.DMP. Report Id: 111014-26875-01.
    I have located the minidump file but I lack the ability to properly open and understand it. tried a text editor but its full of nulls.
    I have uploaded it to my skydrive https://onedrive.live.com/redir?resid=AFD6BF318F3CA1E!106&authkey=!ABLwmVs4ef-2kyU&ithint=file%2cdmp
    if anyone could help me figure out the problem that would be great! I am currently in the process of making sure all my drivers are up to date, and checking my RAM...
    thanks in advance for any help you can offer,
    -LCN 

    Hi,
    WHEA_UNCORRECTABLE_ERROR (124)
    A fatal hardware error has occurred. This fatal error displays data from the Windows Hardware Error Architecture (WHEA).
    ===============================================================================
    Section 2 : x86/x64 MCA
    Descriptor @ ffffe001a058d138
    Section @ ffffe001a058d2c0
    Offset : 664
    Length : 264
    Flags : 0x00000000
    Severity : Fatal
    Error : DCACHEL0_WR_ERR (Proc 1 Bank 1)
    Status : 0xbf80000000000124
    Address : 0x000000045c9c8280
    Misc. : 0x0000000000000086
    L0 cache write error, regarding specifically processor #1 and cache bank #1.
    Remove the following possible software conflicts before we assume this is a bad CPU:
    1. Uninstall Asus Disk Unlocker as well as any other/all Asus bloatware.
    2. Remove and replace AVG with Windows 8's built-in Windows Defender for temporary troubleshooting purposes:
    AVG removal - http://www.avg.com/us-en/utilities
    Windows Defender (how to turn on after removal)
    A.Navigate
    toControl Panel (with icons).
    You can do this by hittingStart
    > Search > Control Panel.
    Once in Control Panel,
    change the drop-down fromCategory
    to
    Large
    and/or Small icons.
    B.Among
    the list of icons, find and click Action Center.
    C.
    Assuming the removal of your prior antivirus software went properly, you will notice for both
    Spyware and unwated software protection (important) and
    Virus protection (important), it'll have a button labeled Turn on now. Click this button (it doesn't matter which, as Windows Defender serves as
    both in Windows 8/8.1).
    3. Navigate to serivces.msc and disable the nVidia Streaming Service, and then restart the computer.
    4.
    1: kd> lmvm dfmirage
    start end module name
    fffff801`a18f2000 fffff801`a18fe000 dfmirage (deferred)
    Image path: \SystemRoot\system32\DRIVERS\dfmirage.sys
    Image name: dfmirage.sys
    Timestamp: Fri Jan 11 16:04:26 2008
    DFMirage driver, uninstall for troubleshooting purposes as it's old, unsupported for Windows 8, and I can see how a driver for a virtual video device can possibly play a role in a crash like this.
    If all of the above fails, there is only so much you can do with a bug check like this until it comes down to a faulty processor that will need to be replaced. Start from 1 and work downward:
    1. Ensure your temperatures are within standard and nothing's overheating. You can use a program such as Speccy if you'd like to monitor temps -
    http://www.piriform.com/speccy
    2. Clear your CMOS (or load optimized BIOS defaults) to ensure there's no improper BIOS setting -
    http://pcsupport.about.com/od/fixtheproblem/tp/clearcmos.htm
    3. Ensure your BIOS is up to date.
    4. If all of the above fail, the only left to do is replace your processor as it is faulty.
    Regards,
    Patrick
    “Be kind whenever possible. It is always possible.” - Dalai Lama

  • DVD CD RW Drive Malfunctio​n. Can anyone pleas help solve this?

    THE  PROBLEM:
    DVD CD RW Disc drive malfunction.  I strongly suspect device failure, but could it be a software issue?
    The drive appears to be working as evidenced by the usual clicking and whirring sounds.  Then, as I usually do, from the START MENU, I open >> Computer >> DVD RW DRIVE (E) , and nothing happens for awhile, as the drive continues to click and whir, and finally a message appears saying,  "Windows Explorer is not responding."
    Note: In the "AUTO PLAY" menu in CONTROL PANEL, I have selected "Take no action" which has been my preference consistently since this computer was new.
    This problem was first noticed when I tried to do a scheduled backup to disc, and was not able to complete the backup.  (In fact, that is just about the ONLY  thing I have used this drive for.)
    In CONTROL PANEL >> DEVICE  MANAGER >> DVD CD ROM DRIVES >> Optiarc DVD RW AD-7561S ATA Device under the GENERAL TAB, It tells me "This device is working properly."
    This is very vexing because obviously SOMETHING is not working properly !
    It does this with all disks, whether they are created by me or by factory, and all disks I tried are pristine.
    ATTEMPTED  DIAGNOSIS AND SOLUTIONS:
    I carefully inspected the head in the drive with a high power eyeloupe and it is absolutely clean.
    Using the CONTROL PANEL utility, I uninstalled the device driver, and then reinstalled it, but the problem persists.  Also, a search for updated drivers returned result:  "No new drivers for this device"
    ADDITIONAL  OBSERVATIONS:
    Ever since new, this drive seems to "vibrate" more than other drives I have used in other computers, as if the disc was "out of balance".  But it does this with ALL disks, so I just assumed it was normal for this drive.
    Also, (Not unlike other drives I have used) it has failed to finalize or finish a disc now and then.  
    COMPUTER  DETAILS:
    HP Laptop Pavilion dv6-1230us
    Product Number:   vh681u#ABA
    Serial Number:   [text removed for privacy]
    OS:   Vista home premium
    Factory installed disc drive:  Optiarc DVD RW AD-7561s
    Will you please advise how to proceed to a solution?
    Thank you.

    This is Not an Isolated incident
    It Seems HP Builds In a Mass Production run of specific Models and if you have ever seen their lines you would know that its alot like an auto assembly line no one person builds a full unit its all Built by about 75 techs.
    Each time My DVD player fails I get the legendary HP DVD PLAY Does Not Respond..... Only thing HP cares about is Do you happen to have an ADP Warranty or Did you BUY and Extended Warranty???
    If your Unit is out of warranty Dont look for them to Offer free Support Look to be charged for any help.
    If HP was Smart and really wanted to Make a killing in the Industry they would offer HP/Compaq Consumers Free Lifetime Support On technical issues.......OMG THATS OBSURD WHAT WAS I THINKING?????? HP Do something for free I need to Have my head examined!!!!
    If your getting the errors and the shut downs and dont happen to have a warranty My Only thought would be Buy A New Laptop from another Manufacturer with a better service record for assisting consumers with tech issues on a free basis.

  • Can anyone help solve this frustrating drop down bug in Adobe Reader 8?

    Has anyone encountered drop downs in their PDF form that don't work in Adobe Reader 8?
    A simple example is my form (stripped back) here:
    http://www.wikski.com/misc/test.pdf
    I've built a form with 22 sections in it, some 1800 lines of code, and now every single drop down has decided to not work in Adobe Reader 8.
    The behaviour is when you select a drop down, it immediately deselects itself and you can't use the element at all.
    I previously had this occur, and by simply deleting the element in LiveCycle Designers ES2 (which is what I've used to create the entire form) and recreating it exactly the same; seemed to fix it. However, I am so far past the point of being able to recreate every drop down this time, I need to actually know what's causing the bug.
    Any help would be greatly appreciated!
    Cheers,

    xfa.layout.relayout(); is required to re-render the entire form in order to have the field change color on Enter event. Without this, the field won't change color in Adobe Reader 8, this goes for all fields not just drop downs. Instead it'll just flicker the color change, xfa.layout.relayout(); makes the color change stick.
    Thanks for your help, I've decided to take the set_focus() event off drop downs and keep it in place just for other field types such as the text input field.

Maybe you are looking for