Combine results of 2 motions, one of them using Group by and a WITH statement

Hello world

I am trying to find a way to combine the results of 2 queries (Oracle 11 g). The first query was a select simple, something like:

SELECT A.ACTDAT, A.ENDDAT, A.ITMCOD, B.ITMDSC, A.PRDORD, A.FPQTY, A.FPACT
FROM Table1 A, Table2 B WHERE A.ITMCOD=B.ITMCOD AND A.VERNUM='VM10' ORDER BY A.PRDORD;

The second query is not so "simple", but:

WITH Tab1 (ProdOrd,Pdate)
      AS (SELECT T.PRDORD, TO_CHAR(T.SYSDAT, 'MM-DD-RR HH24:MI') FROM Table3 T,
Table4 I, Table5 D, Table6 E
WHERE I.ITMCLS = D.ITMCLS AND I.ITMCOD = D.ITMCOD
AND D.DTLTYP = 'F' AND D.TRNSEQ = T.TRNSEQ
AND T.TRNTYP = 'LINTAK'
AND D.LOCATN = '10'
AND E.PRDORD IN (SELECT PRDORD FROM PRDQUE WHERE VERNUM='VM10') 
)
SELECT MIN(Pdate) "1er LINTAK", MAX(Pdate) "Ult. LINTAK" FROM Tab1
GROUP BY ProdOrd
ORDER BY ProdOrd;

For each A.PRDORD in #1 query, the second query should return the

MIN(Pdate)

and

MAX(Pdate)

as follows:

A.ACDAT (from #1 query) A.ENDAT (from #1 query) A.ITMCOD (from #1 query) B.ITMDSC (from #1 query) A.PRDORD (from #1 query) A.FPQTY (from #1 query) A.FPACT (from #1 query) Min (pdate) (from query #2) Max (pdate) (from query #2)
02/04/2014-06:0002/04/2014 08:59:43XXYYZZDescription of XXYYZZ00090001770854359702/04/14 06:1702/04/14-09:16

While separately, both queries return the following results:

Query #1:


A.ACDAT (from #1 query) A.ENDAT (from #1 query) A.ITMCOD (from #1 query) B.ITMDSC (from #1 query) A.PRDORD (from #1 query) A.FPQTY (from #1 query) A.FPACT (from #1 query)
02/04/2014-06:0002/04/2014 08:59:43XXYYZZDescription of XXYYZZ000900017708543597


Query #2:

Min (pdate) (from query #2) (pdate) Max (from query #2)
02/04/14 06:1702/04/14-09:16

Note: PRDORD in Table1 (query #1) est the same as PRDORD in Table2 (request #2).

Hope my question is clear enough.

Any advice or suggestions will be more than welcome!

Hello

Post a small example of data (CREATE TABLE and INSERT for all involved tables, the columns only statements) and the results desired from these data.

See the FAQ forum: https://forums.oracle.com/message/9362002

You want to include the lines of table2 who lines returned in the other tables.  This sounds like the job for an outer join.

You want to ignore the dates on some lines.  That wound like a job for a CASE expression (or if-then-else function specialized, like NVL2).

Tags: Database

Similar Questions

  • I start using adobe lightroom and photoshop with trial version and today I decided to use the creative photography of Cloud (one year) and after the purchase, I received email to confirm that, but my adobe lightroom and photoshop always demo how can I sol

    I start using adobe lightroom and photoshop with trial version and today I decided to use the creative photography of Cloud (one year) and after the purchase, I received email to confirm that, but my adobe lightroom and photoshop always demo how can I solve this problem

    Troubleshooting FAQ: What should I do if I have a subscription, but my application acts as if I had a trial?

    [moved from the download, installation, commissioning creative cloud download &install]

  • Hello, as old microsoft security updates take the largest capacity of my C drive, I would like to remove one of them, who knows if and how I can do?

    I bought my XP Home Edition in 2006. I use it as a second laptop, so it is great for any e-mail, internet and a desk job.

    As the C drive is too full here have already deleted more programs and files, but it is always full.

    Especially with Microdoft security updates.

    Is it possible to remove those between e year after installation and last year?

    And how? Because, under the program, check and delete programs, these updates cannot not be asupprimer.

    Thank you and best regards!

    Robert

    http://answers.Microsoft.com/en-us/Windows/Forum/windows_xp-windows_update/can-i-delete-over-100-foldersfiles-with-a-name/dfa16261-f3d0-4ab7-b519-91631b44b3de>

    You can create more free space in C by

    carrying one of the measures suggested below.

    The default allocation for the restoration of the system is 12% on your C partition

    What is more generous. I have them would be reduced by 700 MB. Click right on your my

    Icon on the desktop and select System Restore. Place the cursor

    on your C drive, go to settings, but this time find the slider and drag

    it to the left until it reads 700 MB and output. When you arrive at the

    Settings screen, click on apply and OK and leave.

    A parameter that might be useless by default is that for temporary internet

    files, especially if you keep no copies on the disk offline. The

    default allocation is 3% of the walk. Depending on your attitude offline

    you could bring this to 1% or 2% of the copies. In Internet Explorer, select

    Tools, Internet Options, general, temporary Internet files, settings for

    make the change. At the same time, look at the number of days is the story

    held.

    The default allocation for the basket is 10% of the disk. Implement

    5%, which should be sufficient. In Windows Explorer, move the cursor

    on your Recycle Bin, right click and select Properties, Global and

    Move the slider from 10% to 5%. However, try to avoid leaving to

    too full as if it is full and you delete a file by mistake, it will be

    bypass the Recycle Bin and have gone forever.

    If your drive is formatted as NTFS another potential gain arises with

    your operating system on your C drive. In the Windows directory of

    your C partition you'll have some uninstall files in your windows

    folder in general: $NtServicePackUninstall$ and $NtUninstallKB282010$

    etc. These files can be compressed or not compressed. If compressed

    the text of the name of the folder appears in blue. If it isn't

    compressed, you can compress them. Right-click on each file and

    Select properties, general, advanced, and check the box before you compress

    contents to save disk space. On the general tab, you can see the amount

    acquired by deducting the size on disk size. Folder

    compression is only an option on an NTFS formatted disk partition / partition.

    Select Start, all programs, accessories, System Tools

    Information, tools, Dr. Watson and make sure that the check box in front of "Append to."

    existing log"is NOT checked. In other words, the next time the newspaper is

    writing it will overwrite rather than adding to the existing file.

    The setting of maximum size by default for Event Viewer logs is too big.

    Reset the maximum value for each log from 512 KB to 128 KB and assign

    crush.

    http://support.Microsoft.com/kb/308427/en-us>

    Select Start, all programs, accessories, System Tools, disk cleanup for

    Empty your trash and delete temporary Internet files. Also

    Select Start, all programs, accessories, System Tools, disk cleanup.

    More Options, System Restore and delete all but the last system

    Restore point. Run Disk Defragmenter.

    --

    I hope this helps.

    I quote Gerry C J Cornell - a regular contributor here

    UTC/GMT is 21:33 Tuesday, April 17, 2012

  • When buying creative cloud, can be used on Mac and Windows with one account?

    If I purchase the creative cloud package, I could make it work on Mac and Windows with my account?

    Hi,

    CC Adobe license can be activated on 2 machines using the same Adobe ID.

    Reference: licenses and terms of use | Adobe

    Kind regards

    Sheena

  • ICloud emails disappear at the time of my Macbook Pro when I delete a message from iCloud of one of them?

    I'm an old Geezer Mac, but a Newbie iCloud. I just put on my two Macbook Pro iCloud email addresses and access e-mail through Apple Mail on both computers. Here are my two questions:

    (1) iCloud emails disappear at the time of my Macbook Pro when I delete a message from iCloud of one of them?

    (2) if I move an e-mail message to iCloud Inbox Mail at Mail Archive on a Macbook, can I delete the message from the second Macbook without losing the archived message?

    Yes, that is what is supposed to happen with an IMAP e-mail account.

    If you move it to a folder on the Mac, not in the iCloud account, you can remove safely icloud.

  • Combine the two projects into one

    I know it is a very popular question and I read many answers excellent previous answers.  The two most popular procedures seem to be simple copy - paste and use clips of compounds with copy / paste.  CPF has improved this process over the years and I ask the question again to get the benefit of current thinking.   I have an iMac (mid-2011) OS X 10.11.4 and FCP worm 10.2.2.  I have two separate events within the same library.  There is a completed project, with all the transitions, effects and music, located within each discipline.    Current ideas on how to combine these two projects into one would be greatly appreciated.

    Thank you.

    Copy and paste is the only method I know.

    Open the project in the timeline first.

    Open the second project in the timeline panel. Only one project appears at the same time.

    Select an item in the timeline and press command + A to select all, then control + C to copy.

    Use the project navigation arrows to return the first project:

    Move the playhead to where copied clips must be glued and press command + V.

    Al

  • I use 4 windows with multiple tabs, but I 'don't know why one of them (window) always close when I restar computer

    I use 4 windows with multiple tabs, but I 'don't know why one of them (window) always close when I restar computer

    Hello, by default the firefox session restore feature only allows you to save last 3 windows open. to change this, type on: config in the address bar of firefox (confirmed the message information where it appears) and search for the preference named browser.sessionstore.max_windows_undo. Double-click it and change its value to 4 (or more).

    http://KB.mozillazine.org/browser.sessionstore.max_windows_undo

  • I have two bookmarks and Favorites in my toolbar how can I delete one of them

    I initially imported my bookmarks on mozilla firefox to internet explore. I have now TWO bookmarks and Favorites in the toolbar. I need only one of them. Please can you advise me on how to remove one of them.

    If you have favorites listed, it will have been added by an add-on such as PlainOldFavorites. You can uninstall the add-on and the Favorites menu disappears - https://support.mozilla.com/kb/Uninstalling+add-ons

  • Now, I have two connections to a single site and want to delete one of them. I don't see where I have an opportunity to do.

    Now, I have two login for a site name and want to delete one of them. I don't see where I have an option to perform this task.

    This has happened

    Each time Firefox opened

    Is when I created the new connection

    Delete a saved here password: Tools > Options > Security: passwords: "saved passwords" > "show passwords".

    See:
    Password Manager - don't forget, delete, modify and import passwords saved in Firefox

    http://KB.mozillazine.org/Deleting_autocomplete_entries

  • I accidentally blocked Facebook profile pictures... How to 'ONE' block them?

    While trying to remove a profile photo (on Facebook), I've accidentally BLOCKED all THE profile photos and received a message "all the profile pictures will be blocked by Firefox" (or something to that effect)... HOW DO I 'ONE' BLOCK THEM? It was NOT my intention!

    This has happened

    Just once or twice

    Is s.o.

    There are instructions for this problem to solve the problems that cause to not show images

  • On startup, I get the messages that applications have stopped working. One of them is (2nd message) IE3SH application has stopped working. How can I fix it?

    Start-up applications to receive messages from windows that have stopped working. One of them is IE3SH application has stopped working. How can I fix it?

    Hi 9gonz9,

    Welcome to the Microsoft Answers site!

    You get this error message when you start the desktop computer?

    You can check if the complete startup items are checked in the msconfig utility.

    1. open System Configuration by clicking Start , clicking Control Panel, clicking system and security, clicking Administrative Tools, and then double-click the System Configuration.

    If you are prompted for an administrator password or a confirmation, type the password or provide confirmation.

    2. click the Startup tab and check if all the items are archived there.

    You can also run a bag of security for your computer and check if this solves the problem.

    http://www.Microsoft.com/Security_Essentials/

    If the problem persists, turn the computer in clean boot and check if all the background program is causing this error message. To help resolve the error and other messages, you can start Windows Vista by using a minimal set of drivers and startup programs. This type of boot is known as a "clean boot". A clean boot helps eliminate software conflicts.

    The steps to perform a clean boot are given below:

    1 log on to the computer using an account with administrator rights

    2. click on start, type msconfig.exe in the start search box and press ENTER to start the System Configuration utility.

    If you are prompted for an administrator password or for confirmation, type your password, or click on continue

    3. on the general tab, click Selective startup, and then clear the check box load startup items. (The check box use the file Boot is not available.)

    4. on the Services tab, click to select the skin all the Microsoft services check box, and then click Disable all

    Note: Following this step lets services Microsoft continue to run. These services include networking, Plug-and-Play, record of events, error reporting, and other services. If you disable these services, you can permanently delete all restore points. Do not do this if you want to use with existing restore points system restore utility

    Once you start the office see if you get the error message. If not then follow the divide and conquer method mentioned in the article below to know which program is causing the problem.

    For more information about the clean boot, follow the below given link:

    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7

    http://support.Microsoft.com/kb/929135

    When you are finished troubleshooting, follow these steps to reset the computer to start as usual:

    1. click on start, type msconfig.exe in the start search box and press ENTER.

    If you are prompted for an administrator password or for confirmation, type your password, or click on continue.

    2. on the general tab, click the Normal startup option, and then click OK.

    3. When you are prompted to restart the computer, click on restart

    Hope this information is useful.

    Amrita M

    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • My parents has been removed and the game of solitaire on their computers. How can I find and download one for them

    My parents has been removed and the game of solitaire on their computers.  How can I find and download one for them

    You still have the Windows CD?

    Follow these steps how add or remove games in Windows XP
    http://support.Microsoft.com/kb/307768

  • How can I get back Admin rights no one has them on the computer?

    How can I get back Admin rights no one has them on the computer

    IIRC, you cannot delete the built-in account named 'Administrator', so check first to see if it's really over:

    If you have XP Pro, then press CTRL + ALT + DELETE twice at the Welcome screen

    If you have XP Home (or XP Pro), restart mode without fail (repeatedly press F8 startup just after reboot) and the administrator account must be indicated on the Welcome screen.

    Unless you have changed it, the password for the built-in Administrator account is blank (no password).

    Once you sign in as an administrator, go to control panel > users and create a new account with administrative privileges (or give these rights to an account existing).  Do not use the built-in for common daily tasks administrator account.

  • I uninstalled Catalyst Control Center who uninstalled a few other related things, one of them my videocard (problem of graphics)

    I uninstalled Catalyst Control Centre, where it took place, it kept blowing - rises, saying it had stopped working. I also read somewhere (not Wikipedia) the Catalyst Control Center was a virus so I uninstalled, which uninstalled a few things related to it one of them my video card I understand now manages the screen resolution, colors, my customization in Chrome color settings, and many other features which I'm just discovering. She brought to the resolution of the screen on my laptop (much it zooms) and reset all my customizations of color to the standard that I hate. I wonder if I have to reset my computer to an earlier date, or if I have to download a new video card. I downloaded the Catalyst Control Center and what came with it but nothing has changed now, options in the control panel > appearance and personalization are missing which is what I used to make my settings and where it let me normally the change of colors (I picked red) are all gone. The screen resolution is still a little low (which means its still slightly zoomed in) in what she was before, and how I liked it, but at least I can still do what I have to (I use this computer mostly for Facebook and games my whole life revolves around both of them, for me so it is essential that this problem may not seem like a large face you (, but for me it is!) So should I reset my computer to an earlier date or download something or what. Help me please. If I have to do a system restore could someone please tell me how or where to go?

    I use Windows Vista 32 bit Business. Thanks guys,-Zane.

    Hello

    First of all, try to download the latest display controls and see if still then restore the computer to a previous state, while it was working fine.

    http://www.ATI.com/products/catalystcontrolcenter/

    http://www.AMD.com/us/products/technologies/AMD-catalyst/pages/catalyst.aspx

  • After installation of Vista business, I have the folder Windows and Windows.0. Can I delete one of them?

    Dear Sir or Madam,
    After installation of Vista business, I have the folder Windows and Windows.0. Can I delete one of them? How can I check that I can delete to free up space. Windows folder takes GB 10.00 and file Windows.0 contains 26.3 GB. Thank you much in advance.

    Noppamas.k

    Mat9

    You can simply DELETE THE WINDOWS. O file if your computer is running norml:http://support.microsoft.com/kb/933212
    This will give you more space.

    If your computer does not correctly him follow these steps:

    The single was is to back up all you produce, programs, data, but does not back up the WINDOWS. O file. You can delete the folder before making the back-up. Back to the top of your files before you begin reinstalling Windows, even if you're reinstalling Windows on a hard disk partition. A clean installation replaces the current version of Windows and all personal files

    On start-up MODE MINIMAL step #7 you want to make sure that DELETE you PARTITIONS
    It will give you an option and a list for delete you old partitions

    CLEAN BOOT

    http://windowshelp.Microsoft.com/Windows/en-us/help/e77344fa-e978-464c-953e-eba44f0522671033.mspx Justin M. Microsoft Support Engineer Answers visit our Microsoft answers feedback Forumand let us know what you think.

Maybe you are looking for

  • memory matching

    Hello I own HP ProBook 430 G1 and do not here find KTH-X3CL / 4G RAM module to add an another 4 GB. I found Kingston KVR16LS11/4, which is comparable. Now it works in dual channel mode and I tried it's OK? Does mem modules in dual channel must be pai

  • Remove line home pg up, pg dn buttons does not

    Laptop HP G60 - 243CL PrtSc remove line home pg up, pg dn buttons does not. they simply stop for some odd reason. How to fix? Thank you laptop is under warranty Bill

  • SSD in my DV6 3216us?

    I have an SSD laptop laying around.  I want to put in my laptop, but don't know if I can!  I think it can work in the slot of the wifi, but to share that I'm not sure!  All answers are appreciated!

  • Compaq laptop screen suddenly begins to roll and will continue to do so even if I hold down the ctrl key.

    My laptop is Compaq Presario CQ50 - 210us Notebook PC running Windows VISTA. All support comes from HP. He developed a mind of your own. The screen starts rolling when he wants to. I have no control over it. This happens with the games already instal

  • What is the version number of the new active stylus for V8P?

    I just got two replacements and the version for both is A02. Is this the last? I had an A00 and A01 an and they were not good, that's why replacements. I expect to be passed A02 now given all the questions people had.