Subquery removal using window functions

Hi,
DB is 9.2.0.8 EE .
select * from FROM bt_osoby osoby , bt_osoby_firmy osf1
WHERE osoby.osb_audyt_st = '1'
  AND osf1.osf_audyt_st = '1'
  AND osoby.osb_id = osf1.osf_osb_id
  AND osoby.osb_nzm_id != 4140963  
  AND osoby.osb_id = ( SELECT MAX (osoby2.osb_id)
                         FROM bt_osoby osoby2
                         WHERE osoby2.osb_audyt_st = '1'
                         AND osoby2.osb_nzm_id = osoby.osb_nzm_id) I'm trying to rewrite above with subquery removal using window functions trick.
select * from bt_osoby osoby , (
  SELECT first_value(osoby2.osb_id) over (partition by osoby2.osb_nzm_id order by osoby2.osb_id desc nulls last) max_osb_id ,osoby2.osb_nzm_id o2_osb_nzm_id
                         FROM bt_osoby osoby2
                         WHERE osoby2.osb_audyt_st = '1') v
                         ,bt_osoby_firmy osf1
                         where
                         osoby.osb_audyt_st = '1'
  AND osf1.osf_audyt_st = '1'
  AND osoby.osb_id = osf1.osf_osb_id
  AND osoby.osb_nzm_id != 4140963
  AND   v.max_osb_id = osoby.osb_id
  AND osoby.osb_nzm_id = v.o2_osb_nzm_idbut rewritten query plan involves huge FTS on BT_OSOBY (much worst then NL over sub query before), how to
benefit from 'subquery removal using window functions' then?
Regards.
GG

Hi,
As you discovered, a query with a sub-query can be more efficient that one without a sub-query.
I would do this using the analytic RANK function (or, depending on your needes, maybe ROW_NUMBER).
WITH     bt_osoby_with_rnum     AS
     select  bt_osoby.*
     ,     RANK () OVER ( PARTITION BY  osb_nzm_id
                           ORDER BY          osb_id     DESC
                    ) AS rnum
     FROM      bt_osoby
     WHERE     osb_audyt_st     = '1'
     AND     osb_nzm_id      != 4140963  
SELECT     *     -- or list all columns except rnum
FROM     bt_osoby_wtih_rnum             osoby
,      bt_osoby_firmy                 osf1
WHERE      osf1.osf_audyt_st  = '1'
AND      osoby.osb_id = osf1.osf_osb_id
;Of course, without versions of your tables, I can't test this.
Note that this does use a sub-query.

Similar Messages

  • Remove Child Window from Parent using WIN API

    Hello all,
    I am using User32.dll to make a parent-child relationship between two VIs. I use SetParent function, and pass the handle of parent VI and child VI to this function. Now, after this relationship has been established, I want to remove the child window from the parent and use it as a independent VI using WIN API. Can anyone help me on this?
    Thanks in advance!
    Fragger Fox!
    -FraggerFox!
    Certified LabVIEW Architect, Certified TestStand Developer
    "What you think today is what you live tomorrow"
    Solved!
    Go to Solution.

    You should be able to set a NULL handle to undo the parent-child relationship and make the child window again a normal top level window. Setting the desktop as parent is probably not the same as being a top level window.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Blackmagic removed desktop audio functionality from Declink cards on Windows.... now what?

    So, Blackmagic removed desktop audio functionality from Declink cards on Windows.... now what? After Effects is not programmed to talk to Decklink cards directly on the audio part, there is no ASIO, or mercury playback for the audio part, Blackmagic says it was never intended to be used as an audio card, yet up to last version of version 9 provided an audio driver for it, as a result, now any application not written to talk to the Decklink card directly, can't use the card for audio playback. I'm wondering if they think that the people that uses After Effects don't need audio at all....   rewiring all the rooms in  the post productions facilities that had all the audio of all the system going out via the decklink cards it is not an option.
    I'm wondering if Adobe is aware of this and if it have plans to support direct connection to the Decklink cards on the audio side of After Effects. This is a huge problem for all the people that uses AE and Decklink on windows and wants a profesiona quality audio monitoring.  Audition, Premiere, all of those can work now, but not AE. I remember some time ago AE used to support ASIO, but I do not see that option anymore.

    Adobe talks with Blackmagic regularly and we were recently made aware of this change. It is, clearly, not something under our control but we can provide feedback to them about your responses to the change.
    You are correct, After Effects does not play back audio through Mercury Transmit like Premiere Pro does. This was something we considered for After Effects CC 2014 (CC), but at the time we were developing this release there was no urgent need to do so, and this would require significant work to re-wire how After Effects plays back audio. We will continue to talk with Blackmagic and evaluate what the best plan is going forward.
    Please don't hesitate to file feature requests for us about these issues: http://adobe.ly/feature_request

  • I have lightroom 5 with 5.7 updated.   I use windows.  My problem is with the spot healer or remover.  It worked perfectly when I click on it it don't have the additional circle with a line attached to it where I can move it to another place for better sa

    I have lightroom 5 with 5.7 verson updated.  I use windows.  My problem is with the spot healer or remover in the develop.  It worked perfectly for a while and then suddenly the other circle with a line attached to it where you can move it to a better spot stopped showing up.  I uninstalled the software and re installed it again but it didn't fix the problem and its still the same.  Help please.

    Does the iPod work OK?
    Does it charge when connect to the computer?
    Does it appear in My Computer?
    Look at the dock connector on the iPod. Compare with the iPod that does work/connect.
    I suspect you have a 2G iPod. Those can only go to iOS 4.2.1
    http://support.apple.com/kb/HT1353#iPod_touch_late2009
    iPod touch (3rd generation)
    iPod touch (3rd generation) features a 3.5-inch (diagonal) widescreen multi-touch display and 32 GB or 64 GB flash drive. You can browse the web with Safari and watch YouTube videos with Wi-Fi. You can also search, preview, and buy songs from the iTunes Wi-Fi Music Store on iPod touch.
    The iPod touch (3rd generation) can be distinguished from iPod touch (2nd generation) by looking at the back of the device. In the text below the engraving, look for the model number. iPod touch (2nd generation) is model A1288, and iPod touch (3rd generation) is model A1318.

  • I am using Windows 7 64-bit on a partitioned hard drive on a MacAir.  The trackpad will only work with a click.  How do I get the full function of tap and scroll?

    I am using Windows 7, 64-bit on a partitioned hard drive on a  2012 MacAir.  The trackpad only works with clicking.  How do I get the full function of tap and scroll? (I have this on a 2011 Mac Pro with 32 bit Windows 7 and it works properly.)

    Windows Control Panel>Boot Camp Control Panel>Trackpad.

  • Elements 11 Organizer window is truncated at top, on iMac running 10.9.2, so I can't use Share function, etc.

    Elements 11 Organizer window is truncated at top, on iMac running 10.9.2, so I can't use Share function, etc.

    Thank you very much.  I changed the resolution from 2048 x 1152 to 1600 x 900, and it showed the bar with the Import, Media ... Create, Share buttons, but did not show the bar at the very top with the red, yellow and green buttons for closing, hiding and maximizing the window. 
    Then I noticed that Apple had an update to Mavericks available.  Since I installed that, I can set the resolution back to 2048 x 1152 and still see the Import, etc. bar.  I can live without the Close and Maximize buttons, but it does seem like there is a bug lurking here that either Adobe or Apple needs to fix. 

  • Using the function WRITE_FORM in a SAPScript window

    hi everyone.
    I need to print the texts of the SO10 transaction, in a SAPSCRIPT page, but i've not able to do so.
    i have a SapScript with 2 pages: FIRST and SECOND,  in the window "POINT2" of the page "FIRST",  I put a  "NEW-PAGE" , between an if condition,  for to call the next page "SECOND". 
    i'm using WRITE_FORM function, in the control program, to send texts from the SO10 to the window "POINT2-1"  in page "SECONDt".
    now, if  I make debbug to sapscript, i can see when: NEW-PAGE it's called and when the ITAB gets all the text, but in the end it doesn't print the text in the sapscript.
    and if I search in the SP02 transaction, for the spool number, it only appears 1 page.
    not 2  like it supose to be.
    can anyone tell me what i'm doing wrong ?
    this is the code that i'm using.
    page: FIRST
    window: POINT2
    /:       POSITION WINDOW
    /:       POSITION XORIGIN '+0' CH YORIGIN '+0' LN
    /:       SIZE WIDTH '+0' CH HEIGHT '+0' LN
    /:       BOX FRAME 10 TW
    /:       IF V_CONT > 5
    /:       NEW-PAGE
    /:       ENDIF
    PH     2º Descripción de error : <N>&IT_PRINT-QMTXT&<><><><></>  ,,&VIQMEL-QMTXT&
    /:       INCLUDE &IT_PRINT-QMNUM& OBJECT QMEL ID LTQM LANGUAGE 'S'
    page: SECOND
    window: POINT2-1
    /E       ELEMENT
    /:       &IT_TEXTO-TDLINE&
    control program
    DATA: IT_TEXTO  LIKE STANDARD TABLE OF TLINE WITH HEADER LINE.
    FORM print_form .
    LOOP AT IT_TEXTO.
        CALL FUNCTION 'WRITE_FORM'
         EXPORTING
           ELEMENT                        = 'ELEMENT'
           WINDOW                        = 'POINT2-1'
         EXCEPTIONS
           ELEMENT                        = 1
           FUNCTION                       = 2
           TYPE                           = 3
           UNOPENED                       = 4
           UNSTARTED                      = 5
           WINDOW                         = 6
           BAD_PAGEFORMAT_FOR_PRINT       = 7
           SPOOL_ERROR              = 8
           CODEPAGE                    = 9
           OTHERS                         = 10
        IF sy-subrc <> 0.
             MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    ENDLOOP.
    ENDFORM.
    <MOVED BY MODERATOR TO THE CORRECT FORUM>
    Edited by: Alvaro Tejada Galindo on Apr 20, 2010 7:38 AM

    Change the command line /: to some paragraph format PH or line feed /.
    /E       ELEMENT
    PH       &IT_TEXTO-TDLINE&
            OR
    /         &IT_TEXTO-TDLINE&
    Also why are you passing the text elemnt to internal table first using READ_TEXT. It can be directly done with INCLUDE Command.

  • Need sample code using windows BitBlt() function to display image in CVI

    Hello all,
    I need a sample code which uses windows BitBlt() function to display image in CVI
    Thank you.
    Bob.

    Hello Bob -
    I'm curious why you'd like to use BitBlt.  What functionality does it offer that you've not seen in the CVI canvas control?
    It's hard to say without knowing what transitions you're looking for, but the canvas is very capable of animating/transitioning.  The place it can fall a little short is if you require access to the alpha channel for transparency.
    I put together a short demo for you - maybe it will address some of what you're looking for.  The important functions are CanvasStartBatchDraw, CanvasEndBatchDraw, and CanvasDrawBitmap.  The animation/transition is driven by a simple UI timer.
    Let me know if you have any questions -
    NickB
    National Instruments
    Attachments:
    CanvasAnimation.zip ‏10 KB

  • Call Library Function Node 'Wrapper.C​reate': Library not found or failed to load. using windows 7 64 bits

    Dear all
    I try to interface my spectrometer (NIRquest from ocean optics) using labview on my 64 bits cumputer using windows 7.
    I have absolutely no problem to run the spectrometer with the program dedicated to the spectrometer (called Spetrasuite).
    I've installed "OmniDriverSPAM-1.66-win64-development-installer.e​xe" and everything went right.
    When I select a VI in LabView (e.g."wrapper_create.vi") from the wrapper.llb, LabView returns an error :
    "Call Library Function Node 'Wrapper.Create': Library not found or failed to load."
    I chek the call library function, but everyting seems to be right :
    I use LabView 8.6.1 and my others *.vi are running perfectly...
    Do you have any idea from where does the problem comes ?
    Thank you very much

    Hello Flanguy,
    In addition to smercurio_fc's feedback I can confirm that LabVIEW 8.6.1 doesn't exist in 64-bit version.
    Officially, LabVIEW 8.6.1 doesn't support Windows 7 either.
    The minimal version of LabVIEW you would need to both support Windows 7 and exist in 64-bit version is LabVIEW 2009 64-bit or any 64-bit versions which are more recent.
    In the two links (1 & 2) you can find more background information.
    Kind Regards,
    Wouter
    National Instruments Belgium

  • When i used windows 8 i lost touch function

    I have brought the woundrful Hp touch smar 600 pc with windows 7  as default os but when i used windows 8  the screen lost touch function and i have heared thatregaing this function could be done by reinstaling this from the hp official site using the id number of the pc but i coud not dothis properly ?

    http://h10025.www1.hp.com/ewfrf/wc/document?docname=c03488148&cc=us&dlc=en&lc=en
    Touch screen doesn't work after upgrading to Windows 8
    Follow the steps below if you upgraded to Windows 8 from a previous Windows operating system and your touch screen stopped working.
    Activate Windows 8 and install updates:
    Press the Windows  + W keys, type Activate Windows into the Search field, and then click the icon that appears in the upper left corner of the screen.
    In PC Settings, click on Activate Windows , wait for your computer to connect to Microsoft, and then follow the onscreen instructions.
    Restart the computer.
    Press the Windows  + X keys, and select Control Panel from the list.
    In the upper right corner of Control Panel, select Large icons from the View by drop-down.
    Click Windows Update .
    Install touch and/or graphics driver updates.
    Restart the computer. If the touch screen still does not work, go on to the next step.
    Check for driver updates at hp.com:
    Go to hp.com (http://www8.hp.com/us/en/support-drivers.html) and click Drivers & Software .
    In the search field, enter your product name or number, and then click Next .
    Select your operating systems from the drop-down, and then click Next .
    NOTE:For more information about your operating system and system type (32 or 64 bit), press the Windows  + X keys, and select System from the list.
    If there are any available graphics drivers, click the plus sign next to Driver - Graphics, and then click the driver name.
    In the Download options and information window, click Download .
    Follow the onscreen directions to download the driver.
    Restart the computer. If the touch screen still does not work, go to the next step.
    Install an older touchscreen driver from the Windows Update Catalog:
    Go to Windows Update catalog (in English).
    If prompted to install a 'Microsoft Update Catalog' add-on, install the add-on.
    Type NextWindow in the search field and press Enter .
    From the list of search results, find the driver named "NextWindow - Input - NextWindow Voltron Touch Screen", version 3.1.6.0, and made for Products Windows 7, Windows Consumer Preview (size 27.6 MB).
    Click the Add button next to the name of the driver.
    Click View Basket in the upper right.
    Click the Download button in the upper right.
    Browse to a path on your computer; such as Desktop.
    NOTE: If a User Account Control message opens, click Yes .
    When the download is complete, click Close .
    Browse to the path chosen earlier and open the folder named "NextWindow - Input - NextWindow Voltron Touch Screen".
    Double-click the .cab file inside this folder to view the contents of the cab file.
    Single-click the first file and then press the keys CTRL + A to select all the files.
    Right-click on any selected file and select Copy .
    Click the Back arrow in the upper left of the window to go back to the folder named "NextWindow - Input - NextWindow Voltron Touch Screen". The only file in this folder should be the one cab file that was downloaded earlier.
    Right-click inside the blank or white portion of this window and select Paste . All of the files from the .cab file are extracted into this folder.
    Double-click the file named NVWVoltronSetupLiteDesktop_3.1.6.0.f.exe .
    NOTE: If a User Account Control message opens, click Yes .
    The driver Setup Wizard opens. Click Next to start the installation. Read and respond to the Windows to install the driver.
    After the driver is installed, restart the computer. If the touch screen still does not work, go to the next step.
    Disable the graphics card:
    Press the Windows  + X keys, and select Device Manager from the list.
    In Device Manager, click the triangle  next to Display adapters to expand the list.
    Right-click on the graphics card, and then select Disable .
    On the Window that reads "Disabling this device will cause it to stop functioning. Do you really want to disable it?", click Yes .
    Restart the computer. If the touch screen still does not work, the computer should be serviced.
    ... an HP employee expressing his own opinion.
    Please post rather than send me a Message. It's good for the community and I might not be able to get back quickly. - Thank you.

  • Can I remove photo shop 3 using windows add and remove after transfering photos to elements 10

    can I remove photo shop 3 using windows add and remove after transfering photos to elements 10. Will I lose any of these photos in elements 10?

    Yes you can remove it and your photos will not be removed. Un install it from add or remove or from the start menu.

  • HT1926 iTunes won't install everything it needs to run.  I remove it from my computer and reinstall it and it keeps saying it.  I am using Windows 7 and the latest update from iTunes.

    iTunes won't install everything it needs to run.  I remove it from my computer and reinstall it and it keeps saying it.  I am using Windows 7 and the latest update from iTunes.

    What does the error message say when you install iTunes and it fails?
    This post was edited by Malignance

  • Null character removal in sap using a function module

    Little background :
    1) we are using a lot of interfaces with legacy and the data in sap has null characters for example : phone#123 .
    the prob is not on sap side but on bw side when i extract this data it converts to hex format and the load fails.
    2) so i wrote a abap function module for the extractor which uses the function modules SRET_TEXT_TO_BINARY and SRET_BINARY_TO_TEXT and passed the variable that has the null character and replaced it with space.
    3) the prob is i get null characters in a lot of fields now and i am not sure how i can pass it to SRET_BINARY_TO_TEXT OR SRET_TEXT_TO_BINARY as they are SAP standard and it takes in just a single variable. i have all my fields in a internal table .
    I apologize for the the length of the message but any help is greatly appreciated.I want to know how to pass a internal table with null in all fields to a standard function module bec . The code is below :
    =======================================================
      CALL FUNCTION 'SRET_TEXT_TO_BINARY'
        EXPORTING
          TEXT                        = input
        TEXT_LENGTH                 = -1
          LAISO                       = '00'
        IV_CATID                    = ' '
        IV_RFC_FOR_INITIALIZE       = ' '
       IMPORTING
        OUTPUT_LENGTH               =
          XBUFFER                     = v_hexa
       EXCEPTIONS
          FAILED                      = 1
          OTHERS                      = 2
      IF SY-SUBRC = 0.
    *Replacing all NULL (X'00') values with SPACE (X'20')
      REPLACE ALL OCCURRENCES OF c_null IN v_hexa WITH c_space IN BYTE MODE.
        CALL FUNCTION 'SRET_BINARY_TO_TEXT'
          EXPORTING
            XBUFFER                     = v_hexa
            LAISO                       = '00'
          IV_CATID                    = ' '
          IV_RFC_FOR_INITIALIZE       = ' '
         IMPORTING
          OUTPUT_LENGTH               =
            TEXTBUFFER                  = output
         EXCEPTIONS
            FAILED                      = 1
            OTHERS                      = 2

    The entire code :
    =======================================================
    FUNCTION YFR1_CA_U_NULL_SPACE.
    ""Local interface:
    *"  IMPORTING
    *"     REFERENCE(INPUT) TYPE  C
    *"  EXPORTING
    *"     REFERENCE(OUTPUT) TYPE  C
    *"  EXCEPTIONS
    *"      LENGTH_TOO_LONG
    *"      FAILED
    This function provides the functionality of replacing the NULL
    characters with SPACE .
      DATA : v_hexa(100) TYPE X ,
             c_space(2) TYPE X VALUE '0020' ,
             c_null(2) TYPE X VALUE '0000' ,
             v_length TYPE i .
      COMPUTE v_length = STRLEN( input ) .
      IF v_length > '100'.
        RAISE length_too_long .
      ENDIF .
      CALL FUNCTION 'SRET_TEXT_TO_BINARY'
        EXPORTING
          TEXT                        = input
        TEXT_LENGTH                 = -1
          LAISO                       = '00'
        IV_CATID                    = ' '
        IV_RFC_FOR_INITIALIZE       = ' '
       IMPORTING
        OUTPUT_LENGTH               =
          XBUFFER                     = v_hexa
       EXCEPTIONS
          FAILED                      = 1
          OTHERS                      = 2
      IF SY-SUBRC = 0.
    *Replacing all NULL (X'00') values with SPACE (X'20')
      REPLACE ALL OCCURRENCES OF c_null IN v_hexa WITH c_space IN BYTE MODE.
        CALL FUNCTION 'SRET_BINARY_TO_TEXT'
          EXPORTING
            XBUFFER                     = v_hexa
            LAISO                       = '00'
          IV_CATID                    = ' '
          IV_RFC_FOR_INITIALIZE       = ' '
         IMPORTING
          OUTPUT_LENGTH               =
            TEXTBUFFER                  = output
         EXCEPTIONS
            FAILED                      = 1
            OTHERS                      = 2
        IF SY-SUBRC <> 0.
          RAISE FAILED .
        ENDIF.
      ELSE.
        RAISE FAILED .
      ENDIF .
    ENDFUNCTION.

  • I get an error message saying, "An error occurred while restoring the disk to a single partition." when I try to use Boot Camp Assistant to remove my Windows partition. Help?!

    I'm trying to remove my Windows partition and delete Boot Camp altogether off my laptop. When I try to remove the partition, I get an error saying "An error occurred while restoring the disk to a single partition."
    Can someone please help?

    Boot from another hard drive or DVD and repair with Disk Utility.

  • Satellite L40-139 - cannot use FN function with Windows 7

    Hi
    I have Satellite L40 - 139 PSL40E laptop, I was using windows Vista. When i was use Vista, i could use "FN" key for sound or others but then i setuped the Windos7 but now i cant use "FN" key for sound, becauze i cant find acessibility driver for Windows 7 that according to my laptop model.
    what can i do ? how can i find ?
    thnx

    Hi Buragh,
    I agree with the user above. You have to install Value Added Package and Flash Cards Support Utility. Both tools you can download here:
    http://eu.computers.toshiba-europe.com > Support & Downloads > Download Drivers
    In forum there are many threads about FN keys. They should be useful so did you read it already? ;)

Maybe you are looking for

  • I installed Boot Camp on Windows 7 PC (No Mac computer!)

    I was trying to install drivers in order to use a Magic TrackPad that I got.  I read somewhere that I had to use/install Boot Camp on my PC.  Well, I did so... however, I have no Mac... it's a 100% Windows 7 PC.  So, I was able to install Boot Camp 3

  • How do I add HTML5 animations from Adobe Edge in my Muse site?

    For now, here are the steps to use Edge output in Muse. Put all output files generated from Edge in the same folder that you want to export Muse output files. (keep all the subfolder structure e.g. edge_includes In Muse, use Object->Insert HTML... me

  • W_ACCT_BUDGET YTD Amount

    Hi all, I am using BI Apps version 7.9.6.3 - Financial Analytics and I was wondering why the fact table W_ACCT_BUDGET which carries only budget GL Balances doens't have a column carrying the As of Date (YTD) amount of the GLs?Is this column exists wi

  • XML and InDesign

    Hello, I just started working with InDesign and I have some questions. Ideally I would like to use InDesign as a scriptable WYSIWYG platform that will compile and XML doc and indicate the (x, y) position of artwork and text. I make educational items

  • URGENT!!! Bios Bug found for P500 series BIOS v2.90. TAIS really needs to fix this!!

    Affected unit: P500-ST6844 PSPGSU-0Q2012 I have had sleep issues with my laptop since I first purchased it back in 2010. I have made a previous post about it here: http://forums.toshiba.com/t5/Batteries-and-Power/L​aptop-turns-off-instead-of-going-to