How can I avoid hard-coding where the internal this select clause?

It is extremely fast, but I have to hardcode the more where clause and I obviously can't do. I know how to get around it by creating a function that takes the CUSTOMER_ID and returns the ORDER_ID for the most recent payment, and it's pretty fast, but I thought it would be interesting to see if there was a way to do this in SQL directly. I also know that better design could make the problem go away.

Really appreciate it if you could take a look and let me know if it is possible to get this kind of performance without Hardcoding.

Thank you

create or replace view customer_view as
Select customer.customer_id,
Customer.Customer_name,
(
Select t.order_id
de)
Select payment.order_id
payment
where payment.customer_id = 1 - <-here's the line where I hardcode the customer_id. is possible to reference the customer_id without this hard-coding?
payment.payment_date desc order
) t
where rownum = 1
) as latest_order_id
of the customer
;

Select * from customer_view where customer_id = 1; <-I want that inner - most select this option to use this customer_id, without having to hardcode it.

Hi Matt,

Something like that could be a possibility (untested)

create or replace view customer_view as
  select customer.customer_id,
         customer.customer_name,
         (select min (t.order_id)
                   keep (dense_rank first order by payment.payment_date desc)
          from   payment
          where  payment.customer_id = customer.customer_id)
           as latest_order_id
  from   customer;

Concerning
Peter

Tags: Database

Similar Questions

  • When I connect my Ipad or Iphone to my computer via a USB cable, I can open the storage folder without using a password. How can I avoid someone else do the same?

    When I connect my Ipad or Iphone to my computer via a USB cable, I can open the storage folder without using a password. How can I avoid someone else do the same?

    This storage folder are you referring? If you are referring to the film, what happens because you have accepted a trust between the iOS device and the computer. If the device has been connected to another computer, it must be unlocked and establish a relationship of trust as well. If you are referring to something different, please explain.

  • How can I avoid reboot to open 'The organiser' A Second Time?

    11 Photoshop running Windows 7

    After that I opened and closed Organizer, I can't reopen it again with my system restarts.

    I know I fell on this some time ago, but forget the fix (if it exists).

    The background task "Update thumbnail" may crash on an item in the catalog that he cannot find.

    Remove fault (s) article and the organiser will close again normally and therefore restart without restarting forced stop of the inside Task Manager.

    Of course to find the offending item can be a task enough.

  • How can I transfer video files to the library in windows media player for an external hard drive

    How can I transfer video files to the library in windows media player for an external hard drive. My os is Windows XP Home Edition and I use wmp 11.

    You have to locate the files on your internal hard drive, using the Explorer, then drag and drop them on the hard drive.  If you don't know where they are on your hard drive, right click on the video file in the library and choose the location of the opened file.

  • Software Distribution Service 3.0. my wallpaper, all my documents, my videos, my photos, my desktop shortcuts, etc. all gone. has had to do a system restore. How can I avoid this in the future?

    XP Professional 5.1.2600 Pack 3. Automatic updates are on. After that an automatic update on Mei and June 2012 identified as Software Distribution Service 3.0 my wallpaper, all my documents, my videos, my photos, my desktop shortcuts, etc. all gone. has had to do a system restore. How can I avoid this in the future?

    Software distribution service 3.0 is a system restore point, not an update.

    When an update is installed a SDS is created.

    To check the name of the update, go to the Microsoft Update Web site and check your update history, search for the date, that the error occurred.

    Also make sure that your system is clean:

    Download, install, update and scan with these full free malware detection programs:

    Malwarebytes (MMFA): http://malwarebytes.org/

    SUPERAntiSpyware: (SAS): http://www.superantispyware.com/

    http://www.Microsoft.com/security/scanner/en-us/default.aspx Security Scanner   

    I guess 'Mei' is your abbreviation of Microsoft Security Essentials under your antivirus protection, is this correct?

    After return with answers to the questions and the results of the analyses.

  • How can I avoid that OE delete access to the jpg attachments

    How can I avoid that OE removing access to attachments containing JPEG files

    Tools | Options | Security. Uncheck the box: "block images...". ».

  • How can I retrieve my files from the clouds after my hard drive has crashed - files were not deleted.

    How can I retrieve my files from the clouds after my hard drive has crashed - files were not deleted.

    Don't know what your problem is - log on to Skydrive and recover the files that you need them, or download the app to Skydrive and they will all be uploaded at the same time.

  • How can I make a DVD of the restore hidden in my external hard drive partition recovery

    How can I make a DVD of the restore hidden in my external hard drive partition recovery because I want to recover my toshiba satellite L840 that does not respond directly to my hard drive so I put my laptop to an external HARD drive and then I want to copy a DVD recovery partition

    Your question is a bit confusing, you can boot the laptop at all? Have you tried booting in safe mode, you can make a recovery DVD set from there, the folder Toshiba.

    With the drive in the Toshiba, you should be able to use a F, F10, F11, or F12 key to activate the installation from the partition hidden started upward.

    Otherwise, you can contact Toshiba, and with the model of the product id number and the laptop for Windows, you can buy a set of disks.

  • How can I avoid losing image changes I've already done when changing the name of a folder?

    How can I avoid losing image changes I've already done when changing the name of a folder? Whenever I have change a folder name (after having published images), Lightroom "updates" the images in this folder and any changes I've made have disappeared!

    Thanks for the update.

    This isn't the correct workflow.

    When you rename a folder outside of Lightroom, it causes the link between this issue and Lightroom to be broken and images will be missed in the Lightroom Catalog

    and if you re-import them same images after that, it will import the original images and not the changes

    Lightroom does not store the original images it contains. It works on the previews and the changes you make are stored only in Lightroom.

    So, you have to rename or move this folder in Lightroom instead of doing outside so that you do not lose your changes.

    To rename a folder, select the folder name in the library module > right click / Control click and select Rename folder.

  • I use Illustrator CC and sent a file to a colleague who uses CS6 where all the layers become a great layer.  How can I send it and preserve the layers?

    I use Illustrator CC and sent a file to a colleague who uses CS6 where all the layers become a great layer.  How can I send it and preserve the layers?

    coledang,

    Save a copy, and in the following options choose CS6.

    In this way, it should open correctly in CS6, and the original document is unscathed.

    You may find that some (new CC) features will not survive the downsaving.

    Edit: Hi SRiegel.

  • When a photo has for example a bright sky beside the dark object, using lights and shadows can cause a 'halo' or double edge to appear. How can I avoid this?

    When a photo for example has a bright sky next to the dark object, using lights and shadows to reduce high contrast can cause a 'halo' or double-edge to appear. How can I avoid this?

    From my experience, this isn't a problem that has a simple solution, such as moving a slider or a combination of the sliders in LR. It requires rather a major change in the technique, at the unit or in office. Some pros (I am not one) tire ALWAYS support HDR or this reason - better transition from highlights to shadows, then tweak the image with much less "heavy" necessary. Another popular technique is the luminosity masking and blending in PS. There is a ton of information on this topic (just do a search on Youtube), but it's not easy to learn or do, but it can eliminate this problem.

  • When my Captivate project is published on my LMS, course opens a new window.  You are able to copy the URL of this window and access the course without logging into the LMS.  How can I avoid this?

    When my Captivate project is published on my LMS, course opens a new window.  You are able to copy the URL of this window and access the course without logging into the LMS.  How can I avoid this?

    Return to your LMS administrator and ask them why they have not put in place more firmly. The scenario you mention should not occur if the LMS is well attached.

    Some LMS have the contents of the course are in a folder outside the web space so that users can access the course URL directly.  For example, Moodle t - it this way and then shot the course content in a temporary folder when the learner clicks on the link ask a module.  No matter how your LMS is supposed to do, it is currently not configured correctly.

  • How can I avoid the automatic renewal of my annual subscription?

    How can I avoid the automatic renewal of my annual subscription? He was selected automatically, what can I do now?

    Thank you very much

    Riccardo

    Hi Riccardo,

    Please contact support by calling/chat for cancellation requests and billing queries:

    Contact the customer service

    * Be sure to stay connected with your Adobe ID before accessing the link above *.

    You can also check the help below document:

    https://helpx.Adobe.com/x-productkb/policy-pricing/cancel-membership-subscription.html

    Kind regards

    Sheena

  • I copied a title several times throughout a project on the same video track. I need to change one thing in each title, but when I change one thing on one, he turns them ALL. How can I avoid this?

    I copied a title several times throughout a project on the same video track. I need to change one thing in each title, but when I change one thing on one, he turns them ALL. How can I avoid this?

    dariusb

    What version of Premiere Elements and on what operating system works - it? At the moment a generalization...

    You need to create the title in the Titler, close the titration module, open the media project, right click on the thumbnail of the title in the media of the project and select duplicate.

    Then drag the duplicate to the timeline. Double-click the duplicate to open the titration module to change the title in doubles.

    If please examine, study and provide more information, so that I can refine (Customize) the answer for you.

    Thank you.

    RTA

  • How can I avoid objects of rendered outside the page?

    Hello

    I have a few large objects in my Web page that stretch the limits of the page in preview mode. How can I avoid making the parts that are off the page?

    Thank you

    Hadi

    img.jpg

    Hi Hadi,

    You must resize the image to fit the page to avoid that it rendered outside the page.

    Kind regards

    Aish

Maybe you are looking for