Get rows where the last row finish off

Hi, i have two tables AND would LIKE TO get data BY combining both.
here IS my data
WITH hist AS
  SELECT To_Date('4/23/2010','mm/dd/yyyy') dt, 999 alias, 'PROC' dom FROM dual UNION ALL
  SELECT To_Date('4/27/2010','mm/dd/yyyy') dt, 999 alias, 'LON' dom FROM dual UNION all
  SELECT To_Date('4/1/2010','mm/dd/yyyy') dt, 111 alias, 'SOC' dom FROM dual UNION all
  SELECT To_Date('4/10/2010','mm/dd/yyyy') dt, 111 alias, 'NAO' dom FROM dual UNION ALL
  SELECT To_Date('3/23/2010','mm/dd/yyyy') dt, 222 alias, 'PSE' dom FROM dual
final AS
  SELECT To_Date('2/26/2010','mm/dd/yyyy') dt, 999 alias FROM dual UNION ALL
  SELECT To_Date('4/22/2010','mm/dd/yyyy') dt, 999 alias FROM dual UNION all
  SELECT To_Date('4/26/2010','mm/dd/yyyy') dt, 999 alias FROM dual UNION ALL
  SELECT To_Date('4/30/2010','mm/dd/yyyy') dt, 999 alias FROM dual UNION ALL
  SELECT To_Date('2/25/2010','mm/dd/yyyy') dt, 111 alias FROM dual UNION ALL
  SELECT To_Date('2/26/2010','mm/dd/yyyy') dt, 222 alias FROM dual UNION ALL
  SELECT To_Date('4/22/2010','mm/dd/yyyy') dt, 222 alias FROM dual UNION all
  SELECT To_Date('4/26/2010','mm/dd/yyyy') dt, 222 alias FROM dual
the output should be as follow(without the extra blank line of course)
DT           ALIAS   DOM
2/26/2010     999     PROC
4/22/2010     999     PROC
4/26/2010     999     LON
4/30/2010     999     LON
4/27/2010     999     LON
4/23/2010     999     PROC
2/25/2010     111     SOC
4/1/2010     222     SOC
4/10/2010     222     NAO
2/26/2010     222     PSE
4/22/2010     222     PSE
4/26/2010     222     PSEso what i am doing here is as follow, take one row in hist table (4/23) and join with final table and give me all rows in final table
where dt <= to the row in hist table and include the row from hist table.
this logic will give me rows 2/26/2010,4/22/10 4/23/2010
then the second row in hist table (4/27/2010) wiill get all rows
in final table that is <= to the current row and pick up the rows starting from the row > than the last row where the 4/23/2010 finished off
in this case the output will be 4/26/10, 4/27/2010(we need to include row from hist)
since there is no row in hist that is greater than 4/30/2010, this date will still be display and dom column value should be taking from the max date in hist
which is 4/27/2010. see output above
this sound a little confusing to explain but look at output of what to expect as output. the other ids should follow the same logic
can someone help write a query for this? thanks

Hi,
Devx wrote:
Frank, thanks again, i ran the query in oracle 11g and oracle 9i. 11g runs ok but 9i doesnt. it looks like the ignore null option is not supported in 9i. That's right: IGNORE NULLS was new in Oracle 10. You should always mention your Oracle version whenever you ask a quiestion, especially if it's as old as Oracle 9.
i will be running this query in 9i. is there any alternative to re-write this query without using last value since ignore null is not supported and the output is not as i expected when i take that keyword out.
i really appreciate your help. please let me know how would i re-write the query. thanksOne work-around is to use LEAD or LAG instead of LAST_VALUE. This means you have to know exactly where (how many rows away) the most recent non-NULL value is, which in turn requires other analytuic funtions, such as ROW_NUMBER, and more sub-queries:
WITH     combined_tables        AS
     SELECT     dt, alias, NVL (dom, '_?_') AS dom     FROM hist
     UNION
     SELECT     dt, alias, NULL          AS dom      FROM final
,     got_r_num     AS
     SELECT     dt, alias, dom
     ,     ROW_NUMBER () OVER ( PARTITION BY  alias
                               ORDER BY          dt
                       )               AS r_num
     ,     COUNT (*)     OVER ( PARTITION BY  alias
                       )               AS alias_cnt
     FROM    combined_tables
,     got_skip_cnts     AS
     SELECT     dt, alias, dom, r_num
     ,     r_num - MAX (CASE WHEN dom IS NOT NULL THEN r_num END)
                             OVER ( PARTITION BY  alias
                           ORDER BY          r_num
                         )                    AS skip_before
     ,     MIN (CASE WHEN dom IS NOT NULL THEN r_num END)
                             OVER ( PARTITION BY  alias
                           ORDER BY          r_num     DESC
                         ) - r_num               AS skip_after
     FROM    got_r_num
,     got_next_dom     AS
     SELECT     dt, alias, dom, r_num, skip_before
     ,     LEAD (dom, skip_after) OVER ( PARTITION BY  alias
                                            ORDER BY      r_num
                             ) AS next_dom
     FROM    got_skip_cnts
SELECT       dt
,       alias
,       NULLIF ( COALESCE ( next_dom
                        , LAG (dom, skip_before) OVER ( PARTITION BY  alias
                                                     ORDER BY         r_num
           )     AS dom
FROM       got_next_dom
ORDER BY  alias
,            dt
;You should be able to calculate bot LEAD and LAG in the same query, but there seems to be a bug that only calculates one of them correctly in this case. The sub-query got_next_dom gets around that, by doing the LEAD in a separate sub-query.

Similar Messages

  • I use Mac 10.4.11 Can I get back to the last version of foxfire I was using?

    I have been using foxfire on my computer for the past few years. Today I was trying to upgrade and when I did, it took off the old foxfire and then told me it could not upgrade. Now I can't get foxfire at all because it is telling me my system is too old. I use Mac 10.4.11 Can I get back to the last version of foxfire I was using?

    Beginning with Firefox 4, Macs must have an Intel x86 processor (which you do NOT have; yours is a PPC Mac) '''''<u>and</u>''''' OSX 10.5 or higher (you have version 10.4)
    *System Requirements: [https://www.mozilla.org/en-US/firefox/4.0/system-requirements/index.html Firefox 4] [https://www.mozilla.org/en-US/firefox/5.0/system-requirements/index.html Firefox 5] [https://www.mozilla.org/en-US/firefox/6.0/system-requirements/index.html Firefox 6] [https://www.mozilla.org/en-US/firefox/7.0/system-requirements/index.html Firefox 7] [https://www.mozilla.org/en-US/firefox/8.0/system-requirements/index.html Firefox 8]
    '''''The good news''''' is that Firefox 3.6.24 still supports OSX 10.4 and Macs with the PPC Mac architecture. '''''The bad news''''' is that support for the Firefox 3.6.x series is likely to end in the first quarter of 2012.
    *System requirements: [https://www.mozilla.org/en-US/firefox/3.6/system-requirements/index.html Firefox 3.6.x]
    *Download Firefox 3.6.24: https://www.mozilla.org/en-US/firefox/all-older.html
    *Also see --> http://support.mozilla.com/en-US/kb/Installing+Firefox+on+Mac
    You can try the third-party product '''''TenFourFox''''' that supports PPC Macs. Firefox 8 version of '''''TenFourFox''''' is available. The product is based on Firefox released versions. All support is provided by the developer, not by this site:
    *Home page: http://www.floodgap.com/software/tenfourfox/
    *Developer's blog: http://tenfourfox.blogspot.com/
    *'''''VERY IMPORTANT'''''; '''read this carefully''': https://code.google.com/p/tenfourfox/wiki/PluginsNoLongerSupported
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''

  • How do i get rid of the last import album on my iPhone?

    How do i get rid of the last import album on my iPhone its taking up almost half my storage of my whole phone?!!

    This is the iPhoto for Mac forum - you need the iPhone forum for iPhone questions - I will request tha tit be moved
    LN

  • HT4859 Can't backup my Iphone to Icloud. Keep getting error message, "The last backup could not be completed".  Any suggestions?

    I keep getting error message, "The last backup could not be completed" when trying to backup Iphone to Icloud.  I have plenty of storage space.  Phone is plugged in, connected to WI-FI & is locked.  Does anyone know what is wrong?  Thanks

    HELP!  Is there anyone out there who knows how I can fix this????
    Thanks!

  • Ipod cuts the last five seconds off songs

    My ipod allways cuts the last five seconds off songs. How do I stop it doing this?

    Hi, Try deleting album artwork from songs on the ipod. Worked for me.

  • IPad / iTunes sync gets stuck at the last step

    Whenever I sync my iPad and iTunes, it doesn't complete the last step and gets stuck on "Waiting for items to copy".
    First it was with "Step 7 of 7: Syncing Genius data to iPad", so I deleted all Genius stuff and links to it. Since then it gets stuck with: "Step 6 of 6: Synching Artwork to iPad" and just hangs with it forever.
    I am an Apple newbie, the iPad 3 is my first Apple appliance.  What can I do to avoid having to exit syncing by unplugging the iPad? (NB iTunes runs on a PC with Windows 7.)
    Thanks, Joseph

    It may be that you have a couple of problem files. I have a similar issue, where some music, that I purchased via iTunes, won't sync on to my iPod.
    I'd suggest that you start my turning off as much syncing as you can in iTunes. Use iCloud to transfer your calendars, contacts etc.
    Then try syncing some of your music and other media manually. If there are errors, then iTunes should flag them up by saying "Could not copy xxxx because ..."
    Personally, I only sync media manually, as I don't always want iTunes to perform a full sync every time I start it up. As my iPad is set to sync wirelessly, it connects to iTunes every time I open it.

  • LTE signal getting worse over the last 4-5 months in 84106

    I live in an area of Salt Lake City called Sugarhouse, and for the last 4-5 months it seems like the LTE service in this area has just gotten worse and worse. The area in particular is South of I-80 along Highland Drive.
    At first I thought that it was my phone (Droid Charge) so I went through troubleshooting at a store, which included resetting my phone to defaults and getting a replacement SIM card. Neither solved the problem, and I didn't think the final step of replacing the phone was necessary because the same phone gets full LTE signal at work downtown and in many other areas.
    Since then, I've purchased a Verizon iPad with LTE and have seen the same exact behavior on both devices. They will both drop to 3G in most areas of the house including outside in the open. The Droid Charge has also dropped to 1x a few times, but I don't think that's happened since the recent update. Sometimes the devices will bounce back and forth between LTE and 3G, which is bad because if I forget to put my phone on the charger overnight, or forget to set it to CDMA only, I'll wake up with a dead phone.
    Something else that I've noticed during the last month or so, is that when I do find a spot in my home that I can get 1-2 bars of LTE signal in, that particular spot is good for a limited amount of time. I've left my phone and iPad in a spot that has LTE signal, and anywhere between 10 minutes to 6 hours later the device will drop to 3G. Sometimes I'll be able to get LTE back if I move the device around a bit, sometimes it will stay on 3G despite repositioning.
    I'd be happy to offer up any additional information if needed. I'm desperate to get a good stable LTE signal! Thank you.

        Hello Meerkatderp! I'm sorry to learn of any issues you have encountered in the last few months! I appreciate all that you have tried in an attempt to get this resolved too. I'm happy to help you w/your 4G data connection! Because you gave such thorough information about the location in which you are having trouble, I was able to locate the area on our coverage map. This area is showing to be covered nicely with 4G service, with towers all along Highland and south of I80. I did check my resources to check and see if any trouble tickets have been made for the area, and I don't see a problem reported there.
    This doesn't mean I doubt you in the least! (I just want to make sure that is clear) But, what it does do is point my attention to your device. I'd like to ask you to try some troubleshooting steps with your phone. I have listed them for you.
    1) Press and hold the power button, turn on Airpland Mode, wait 15 seconds, then press and hold the power button again and turn off Airplane Mode.
    2) Please remove the battery and the SIM card from the phone for about 60 seconds, reattach, power on, and monitor.
    3) Complete a master reset on the phone, once you have backed up the information. Here are the steps:
    http://bit.ly/SjwrC2
    4) Here is an application that is recommended from the manufacturer of your device to help with this as well:
    http://bit.ly/Ov7Dq1
    Please let me know how these steps work out, so we can make sure you are able to enjoy the 4G network.
    Christina B
    VZW Support
    Follow us on Twitter @VZWSupport

  • Terms and conditions not getting displayed on the last page

    Hi All,
    I have to display a smartform, on the front side of the page i have to display material details and on the back side of the page i have to display terms and conditions. I' am unable to print the material details and terms and conditions in duplex mode, but on the last page only material details are getting displayed, terms and conditions are not getting displayed.
    Can you please help me how to make the terms and conditions get printed on the back side of the last page.
    Thanks,

    I'm a bit confused by the statement "I' am unable to print the material details and terms and conditions in duplex mode".
    I suppose you meant to say "I am able to print the material details and terms and conditions in duplex mode", correct?
    If the problem is that on the last form page, the T&C is not getting printed on the back of the form, you could force the T&C page by using a flow logic command as the very last element of the main window, which gets processed when all the data is already output. For the command, use the 'Go to New Page' and specify the page name for the Terms & Conditions.
    In case this causes an issue that the last page is printed twice (since the T&C page is likely defined with the next page being NEXT_PAGE), then copy the already existing T&C page, call it LASTPAGE and leave the Next Page attribute empty.

  • Getting information about the last opened document?

    Hi there!
    I've got a question about the reader and it's opened documents: Is there any possibility to get any information about a document, that was already opened by the Adobe reader?
    Example: I open xyz.pdf, and after closing the reader, i want to check what the last page was, the user looked at. Or the time, when this document was closed.
    thanks
    Daniel

    Try something like this:
    Font font = UIManager.getFont("Button.font");hope this helps!

  • When iCloud goes to back up on my iPad, I get an error "the last backup could not be close

    iPad won't backup to iCloud - error message says "The last backup Could not be completed" - Have tried several times.

    Welcome to the Apple Community.
    If your back up continually fails, you might try turning off back up on your mobile device (settings > iCloud > storage & backup) and then deleting the backup file from iCloud by swiping the backup file on the mobile device (settings > iCloud > storage & backup > manage…) and then turning back up on again.
    Being able to back up to the cloud can be very useful, especially if you don't have access to a computer or have infrequent access to one, however unless you specifically need to use iCloud for back up, you will find backing up to iTunes significantly more convenient and possibly more reliable.

  • My iPad gets stucked in the last step of the sync with the computer.

    When connecting the iPad to the computer the iTunes starts, reconizes my iPad and starts the sync of the iPad.
    It syncs the contacts, calendars, pictures, music, etc, but in the last step (7th; "finishing Sync") it stucks and stays for ever without finishing.
    I cannot load a previous backup because as soon as I connect the iPad to the computer the Sync process starts and no button is available.
    I've tried to load again iTunes to start from the begining but it is still saying the same, that the Sync process is finishing and is blocked there.
    Any help?
    Thanks a lot.

    Hi Demo,
    I've tried what you say but, if I'm doing it right, it doesn't work because after rebooting it goes again to syncing and stucks on the last step.
    Nevertheless let me check if I'm doing it right; When you say "Before you restore from the backup, quit iTunes, ...." you mean "Before" or "After" because I don't understand how I could reboot the iPad BEFORE I restore from the Backup if it is already restoring.
    Just let me write down the procedure to check that it is the right one:
    1- I launch iTunes (iPad not connected) and go to Edit>Preferences>Devices, and I check the box to Prevent the iPad to syncing automatically. I click OK.
    2- I quit itunes.
    3- I connect the iPad to the computer.
    4- I launch iTunes.
    5- I go to Restore from Backup
    6- Restore from Backup is finished
    7- I quit iTunes
    8- I disconnect the iPad from the PC
    9- I reboot my PC
    10- I reboot my iPad by holding down on the sleep and home buttons... iPad stars.
    11- I connect the iPad to my PC.
    12- I launch iTunes
    13- I click on sync button.
    If the procedure is right then my problem must be another one because when I do it and it starts syncing again the same problems comes back again and the syncing never stops at the last step.
    Thank you anyway for your time and support.
    Best regards,
    Francisco

  • Table where the last name and the first anme are stored

    Hi ALL,
    I would like to know the table in which the last name and the first name of the employee gets stored?

    Hi,
    You can use the table PA0002 for first and last name of the employee.
    Please refer the below fields in table PA0002
    First name- PA0002<VORNA>
    Last Name-PA0002<NACHN>
    Second Name-PA0002<NACH2>
    Regards
    Raviiiiiiiiiii

  • IE cuts the last few seconds off my FLV videos

    I have FLV (audio & video) clips on my website that
    automatically play, then automatically take you to the next
    scene...
    work fine in Firefox, but not in IE...IE seems to cut off the
    last few seconds before going to the next scene....anyone know
    why?...there's also random audio "pops" only in IE....it's like IE
    can't keep up with the frame rate or something?!?
    (My FLV clips are not embedded in the SWF, but set up as
    progressive in the same root directory on the same web server.)
    check it out:
    (2 clips: - "intro" & then click on any section and
    there's another "4-second" clip)
    http://mikepentaproductions.com/
    any feedback would be greatly appreciated...this is my first
    website and I can't believe how many issues I've been having,
    trying to please both IE and Firefox...it's a conspiracy, I tell
    ya!!
    thanks for your time
    -Mike P.

    encourage the use of firefox
    https://www.google.com/adsense/referrals

  • TS2570 My I Mac turns on and gets to where the apple shows and then turns off?

    It was having problems with the wheel just spinning so I tried to start in safe mode.

    Question (?) Mark, Blinking Folder, or Gray Screen at Startup
    These are related but not identical issues. Their causes are outlined in Intel-based Mac- Startup sequence and error codes, symbols. Solutions may be found in:
    A flashing question mark appears when you start your Mac
    Mac OS X- Gray screen appears during startup
    In most cases the problems may be caused by:
    Problem with the computer's PRAM - See Resetting your Mac's PRAM and NVRAM.
    Boot drive's directory has been corrupted - Repair with Disk Utility.
    Critical system files are damaged or deleted - Reinstall OS X.
    The disk drive is physically non-functional - Replace the hard drive.
    Repair the Hard Drive and Permissions
    Boot from your Snow Leopard Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Utilities menu. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer.
    If DU reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    The main difference if you are using Lion or Mountain Lion is that you must first boot from the Recovery HD:
    Boot From The Recovery HD:
    Restart the computer and after the chime press and hold down the COMMAND and R keys until the menu screen appears. Alternatively, restart the computer and after the chime press and hold down the OPTION key until the boot manager screen appears. Select the Recovery HD and click on the downward pointing arrow button.
    Reinstall Snow Leopard Without Erasing The drive
    1. Repair the Hard Drive and Permissions
    Boot from your Snow Leopard Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Utilities menu. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer.
    If DU reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    2. Reinstall Snow Leopard
    If the drive is OK then quit DU and return to the installer.  Proceed with reinstalling OS X.  Note that the Snow Leopard installer will not erase your drive or disturb your files.  After installing a fresh copy of OS X the installer will move your Home folder, third-party applications, support items, and network preferences into the newly installed system.
    Download and install Mac OS X 10.6.8 Update Combo v1.1.
    Reinstalling Lion/Mountain Lion Without Erasing The Drive
    Boot to the Recovery HD: Restart the computer and after the chime press and hold down the COMMAND and R keys until the menu screen appears. Alternatively, restart the computer and after the chime press and hold down the OPTION key until the boot manager screen appears. Select the Recovery HD and click on the downward pointing arrow button.
    Repair the Hard Drive and Permissions: Upon startup select Disk Utility from the main menu. Repair the Hard Drive and Permissions as follows.
    When the recovery menu appears select Disk Utility. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the main menu.
    Reinstall Lion/Mountain Lion: Select Reinstall Lion/Mountain Lion and click on the Continue button.
    Note: You will need an active Internet connection. I suggest using Ethernet if possible because it is three times faster than wireless.

  • Online login doesn't get rid of the page access (taken off from permlist)

    I have located the user ID and all it's 4 ( Nav homepage, Procs profile, Primary, Row security ) permlists
    As I am taking off pages access from the Primary permlist or even on all the other 3 permlist, I am expecting for that page access to disappear as i login as that user.
    I am wondering if there is another step missing to remove pages access from a user ID.
    As i am new to PS security.
    Thanks

    Found that roles of that user have permlist attached to themself

Maybe you are looking for

  • File sharing network problem

    I have an Airport Extreme (G) base station with an Airport Express acting as a WDS extender. I have two client Macs - a 24" iMac (Intel Dual Core) and an iBook (G4). There are a variety of other clients as well - 2 wireless-G tivos, a Win XP laptop,

  • Automatic Backup not working like it should

    Is anyone else having any problems with their iDevice not doing the automatic iCloud backups?  Ever since I installed iOS 5, I have had to run the iCloud backup manually and its a little concerning that it wont run automatically.

  • Current date in date range formula

    I have a report where I only want to see records if the current date is between 2 dates on the report ( {@ Eff From} and {@Eff To} ) I will try to show example below: Part A - Eff From 06-04-2007   Eff To 12-31-2020 Part B - Eff From 06-04-2007   Eff

  • Configuring Time Capsule's sleep mode

    Hi everyone, I have a time capsule 1T, which I use to back up my files and also as an external hard drive for my music and photos. The problem is that it often goes to sleep during a slide presentation of my photos, or after it played a song of more

  • Doubt about home button in iphone 4S

    I have an iphone 4s one month ago. Sometimes when I press the home button when the phone is locked, the screen lights on for a second and after that, the screen gets off again and the phone continues locked. I have to press again the home button, so