Can this be solved by a nested query?

Hello,
Can anybody help me? Thanks a lot.
We have a test system that test production units, and output data to the TestData table in the database. The TestData table schema is like the follows. For each unit, it may pass the test system for multiple times, and each time the system generate a row of data in the table. 'Not Found' means the unit passed that time of test, no defect is found. If a defect is found the defect will be logged in the table.
The question is: I want to form a new table named TestRslt based on the TestData. The TestRslt table should be like follows, ie. each unit should have only one row of test result. For units tested with both Defect-A and Defect-B, only the row containing Defect-B will be appear in the result table. For a unit of which Defect-B is found in multiple tests, only the first time test data will be appear in the result table.
TestData
UnitID TestNumber Defect
unit-A 1 Not Found
unit-B 1 Defect-A
unit-B 2 Defect-B
unit-B 3 Not Found
unit-B 4 Defect-A
unit-C 1 Defect-B
unit-C 2 Defect-B
unit-C 3 Defect-A
TestRslt
UnitID TestNumber Defect
unit-A 1 Not Found
unit-B 2 Defect-B
unit-C 1 Defect-B

Hello, another alternative to get the corresponding TestNumber could be something like this:
select UnitID,
         case
            when db is not null then db
          when da is not null then da
            else d
        end d_final            
  from
    select UnitID,
             min(decode(Defect,'Defect-A',TestNumber,null)) da,
             min(decode(Defect,'Defect-B',TestNumber,null)) db,
             min(TestNumber) d
    from table
    group by UnitID
  )You can use this to join with your original table, like this:
select UnitID, TestNumber, Defect
from tabe,
       -- previous query
       (select UnitID,
                case
                   when db is not null then db
                  when da is not null then da
                   else d
               end d_final            
         from
           select UnitID,
                    min(decode(Defect,'Defect-A',TestNumber,null)) da,
                    min(decode(Defect,'Defect-B',TestNumber,null)) db,
                    min(TestNumber) d
           from table
           group by UnitID
       ) aux
where aux.unit_id = table.unit_id
      and aux.d_final = table.TestNumberI hope you could get your solution soon.

Similar Messages

  • PIR's and batch management issue, can this be solved in APO ?

    Hi All,
    I've an issue. I honestly dont know where I can get a solution for that and thats why i will post it in mm and also pp forum.
    Here is my issue.
    All materials are batch managed. Each and every customer can get only certain batches and not all batches meet the requirement of a customer. Lets say I have 3 plants (plant 1, plant 2 and plant 3) and I have 3 customers ( cust1, cust2 and cust3). Lets say I get a demand for material and I create PIR's in plant 1. when I run MRP, it will generate planned orders. I convert that into purchase req and then into STO for plant 2. when plant 2 doesn't have the raw material to process into semi finished, I will create and sto from plant 2 to plant 3 to get the raw material. The reason we create sto to plant 2 initially is because it has to process something before it sends it to plant 1. so the link is from customer 1 --> plant 1 (finished goods) -- > plant 2 (semi finished) --> plant 3 (raw material).
    Right from raw material it is specific to a customer. i.e. not all raw material batches from plant 3 will be accepted by customer 1.
    so when the demand flows from customer 1 to plant 2, is there anywhere that I can keep track of for which customer that order is going and select raw materials based on the end customer ?
    Can this be solved in APO ?

    Hi sapcrs,
    Your requirement is meet the solution of configuration of the following scenario.
    customer 1 --> plant 1 (finished goods) -- > plant 2 (semi finished) --> plant 3 (raw material).
    The conditions are
    a) Raw material is batch managed
    b) Keep track of order flow
    Solution:- 
    1) Maintain raw material as batch managed in R/3.  Suitably class and characterisitics to be developed to send the information to APO as that the RM is batch managed. 
    2) The Bom of semi-fnished item at plant-2 to be maintained with raw material.  The source of supply has to be linked with plant-3.  The RM will be externally procured from plant-3 for plant-2 which is batch specific.  The Bom item will be send to APO as PPM which contain all bom and routing details.
    3) Now once RM is ready at Plant-3, it will be sourced to plant-2 and at plant-2, semi-fnished item will be made with the production orders triggered from bom & routing data at plant-2
    4) Now semi-finished item is ready at plant-2.  Once it is ready, it has to be sent to plant-1 for mfg FG.  This can be achieved by creating lane between plant-1 and plant-2. 
    5) Through lane, semifinished item reaches plant-1 which is made at plant-2 which contains RM made at plant-3 which is batch specific.
    6) Using semifinished item, Finished product can be made at plant-1
    7) Now your final requirement is to track all order flow changes.  This can be achieved by mechanism in APO called pegging.  Using pegging, the order flow can be tracked right from FG to RM.
    Regards
    R. Senthil Mareeswaran.

  • TS2621 I receive emails on my Iphone while Outlook is open on my computer but they quickly disappear.  Can this be solved?

    I receive emails on my Iphone while Outlook is open on my computer but they quickly disappear.  Can this be solved?

    No. You really can't do that. Not easily at any rate. You would have to set them both up to use POP3, but even then there is no way to guarantee that the phone won't poll the server prior to your computer doing so, pulling down the message from the server.

  • I have just updated software updates for my iMac and I am still not able to get Firefox 4 to be accepted by Snow Leopard - how can this be solved?

    It appears that a number of people have had this problem, but I have not found a comprehensive location that will solve the compatibility problem between Snow Leopard and Firefox 4. Does this require the services of a tech to solve?

    Try:
    - Powering off and then back on your router.
    - iTunes for Windows: iTunes cannot contact the iPhone, iPad, or iPod software update server
    - Change the DNS to either Google's or Open DNS servers
    Public DNS — Google Developers
    OpenDNS IP Addresses
    - For one user uninstalling/reinstalling iTunes resolved the problem
    - Try on another computer/network
    - Wait if it is an Apple problem
    pinto123 wrote:
    i did every thing you said and when i went to restore this is what happened: the ipod software update server can not be contacted. make sure your network settings are correct and your network connection is active, or try again later. what do i do to restore.     i used the last way to do it the dfu

  • The tempo goes irregular while recording.... I have Logic 9 with a Presonus FireWire Console... can this be solved with a professional hardware clock? Thank you.

    Hello... I use Logic Studio 9 and a Presonus Firewire console.... the tempo goes irregular (mostly slower) while recording... I guess this is due to any digital incongruence... I just need to know if this problem can be solved by using a professional clock (Apogee Rosetta, for example).. Thank you.

    Probably the reason why no one has answered you, is because it could be a BAZILLION things.
    You haven't mentioned what OS, what computer, your harddrive....
    Where to begin??

  • App Store, Pages 5.0, Evernote, and other Apps will not fully function after installing Mavericks. What is the issue and how can this be solved?

    Hello all, I could use some serious help on some major issues I have been having after installing Mavericks on my system (specs stated below). Never has a mac felt ever so rebelious and broken before in my lifelong period of using these systems. Anyway, after installing system 10.9, I had opened the mac App Store upon seeing that applications such as my iWork suite all had free updates. However, when I would attempt to navigate to the updates window, it would not respond to my various attempts. I then tried to get there by the system's menu bar and to my dismay, nothing would work when I clicked on it, not even the apple logo menu. I later quit the application using Command-Q and opened up the App Store by the apple menu option 'Software Update...' instead. Though it looked promising since the updates window did open, all update buttons or even '...more' info buttons were unresponsive.  These same problems persisted even after restarting my computer. I had also attempted to see if repairing definitions would help by booting from the recovery start-disk and using disk utility but the repairs it carried out apparently had nothing to do with my issue. Finally, I was able to update to the new iWorks suite (which interestingly did not replace the iWorks '09 suite) by following the notification that asked about allowing automatic updates which I did.
    Once trying to use Pages 5.0, I soon noticed that all I could do was merely type in a new document and change various options via key commands. Neither the inspector or top bar menus would respond to any place I click. Similarly, Evernote only starts up on the last used note and merely allows me to scroll through it. The top bar menus, the note select pane, and even clicking inside the note to input text are all not functioning and uninfluenced by any mouse clicks.
    I have noticed other apps that will not respond to any sort of input, but I still have not explored all applications to know what the issues of each may be. However there are some applications that work such as Safari, Google Chrome, dolphin, iWork '09 including Pages '09, and others.
    I do hope that I can avoid rolling back my system, but in the meantime, it has been quite the obticle course to use my computer for all of my school purposes.
    Any help is very much appreciated,
    Thank you!
    DT
    MacBook Pro 13-inch, Mid 2009
    Processor  2.26 GHz Intel Core 2 Duo
    Memory  4 GB 1067 MHz DDR3
    Graphics  NVIDIA GeForce 9400M 256 MB

    I also forgot to note that this problem also persists with the new iBooks application. I cannot get past the 'Get Started' screen or access the iBooks Store. Again, all top bar menus are unresponsive.
    DT

  • No sound on Iphone 4S after pulling headpones, how can this be solved?

    Hi all,
    I recently bought my Iphone 4s and everything was fine.
    However when I pulled out my headset yesterday, there was no sound coming out of my phone.
    There is sound when the headphones are plugged in, but when they are removed I can't hear music, video's and games.
    Any one experiencing the same?
    Thanks in advance!

    Hi! I had the same issue on my IPhone4. I talked with AppleCare Support and the advisor suggested me to backup and restore the device with ITunes WITHOUT synchronize any app (I had about 30 apps) and now it's working!!!
    Then wait some hours and after try to synchronize 5 app to find which one caused the issue.
    Try this way!
    I hope I had been helpful!

  • My iphoto did not separate 7 days of our trip in several locations.  How can this be solved?

    My iphoto did not separate 7 days of our trip in which I took some 340 pictures that are all on the same Event.  How do I get them separated by days & dates so that I can identify them?  These were all taken in Scotland & England!

    Hi lewisbr,
    Thanks for using Apple Support Communities.  This article has some information on how to separate imported events by day that may help:
    iPhoto 9.5: Merge or split events
    http://support.apple.com/kb/PH15131
    Autosplit an event
    You can split one or more events into smaller events based on the date or time the photos were taken.
    For example, if you have an event that includes photos taken during an entire day, such as at a birthday brunch and an evening barbecue, you can have iPhoto split that larger grouping into smaller events that cover a shorter time period.
    Set the event time frame in iPhoto preferences.Photos imported from now on will use this time frame until you change it.
    To split an event that’s already in your photo library, select the event and choose Events > Autosplit Selected Events.The event you selected is split into smaller events based on the new time frame you set in step 1, but the other events in your library are unaffected unless you repeat step 2 for them.
    Tip:   You can also select more than one event to autosplit. Drag your pointer to enclose two or more events that are next to one another. To select events that aren’t adjacent, click the first event to select it, and then hold down the Command key as you click additional events.
    Cheers,
    - Ari

  • CAN THIS BE SOLVED?

    MY IMAC G5 SAYS, "YOU CANT OPEN THE APPLICATION "___" BECAUSE IT IS NOT SUPPORTED ON THIS ARCHITECTURE." IS THERE A SOLUTION FOR THIS?

    You did not name the app, nor the version of OS X (presumably Leopard), but search and see if there was a former version that worked in the PPC environment on your version of OS X.
    For example, Office 2004 will work, where as Office 2008 and 2011 will not work.

  • When trying to put a billing address in for an iphone repair it says some characters are invalid. How can this be solved?

    Cant submit my address for billing for repair. Says invalid characters used.

    I am having the same problem.
    I get this message. The address contains invalid characters.
    Any solution?

  • After updating Firefox sites are only displayed in text. How can this be solved OR changed back to the old version?

    Startpage is normal but after connecting further only text is displayed

    I also forgot to note that this problem also persists with the new iBooks application. I cannot get past the 'Get Started' screen or access the iBooks Store. Again, all top bar menus are unresponsive.
    DT

  • In safari, when the windows is full screen in "top sites" you have to click two times to select a page. Can this be Solved?

    It happens with all macs? It is a bug of safari?

    "Clear the Cache": Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"
    "Remove the Cookies" from sites causing problems: Tools > Options > Privacy > Cookies: "Show Cookies"
    See http://kb.mozillazine.org/Clearing_the_cache and http://kb.mozillazine.org/Cookies
    See also http://kb.mozillazine.org/The_page_is_not_redirecting_properly

  • My husband and I share an ITunes account. He gets my apps and I get his. How can this be separated. I am also getting his contacts. My Icloud is turned off!

    My husband and I share an I tunes account.
    This was never a problem until I Cloud was born.
    I have turned off the Icloud on my I phone4 all together.
    He has Iphone 4S and is getting all the apps I purchase and I am getting his contacts.
    How can this be solved. If I get my own Itunes account do I have to purchase my apps again?
    Help!

    If you use another iTunes ID you can keep your apps, but you need to do some settings first.
    Read the hlep infos.
    http://support.apple.com/kb/HT4895
    I have purchased music, apps, or books with multiple Apple IDs. How can I get all of this content onto my iOS device?

    First, you need to copy all of your purchased content so it is on the same Mac or PC with iTunes. This computer should be the one you sync your device with. For more information on how to move your content, see these articles:
    Mac:  iTunes for Mac: How to copy purchases between computers
    PC:  iTunes for Windows: How to copy purchases between computers
    Next, authorize your computer to play content with each Apple ID in iTunes. Once your computer is authorized for all your content, it can be synced to your iPhone, iPad, or iPod touch. 
    And about the iCloud, I'm not very sure about that. I think maybe you don't need to turn off all of the iCloud settings, just the items you don't want to sync with your husband. For the apps, you can cancel 'automatically download purchased items' in the settings on iOS devices.
    May these informations will help you.
    JHinSel

  • Eircom webmail is difficult to use since i downloaded mozilla 4 How do i go back to 3.6 or can this problem be fixed?

    I use Eircom webmail for email. Since I downloaded Mozilla 4 it is not working properly. It is impossible to open mail except by using a circuitous route also I cannot delete messages straightforwardly. Mozilla3.6 never caused this problem. Can this be solved and if not how do I reload 3.6. If I cant get a resolution I shall have to use Chrome as my browser. Thanks in advance Mary Lordan

    EgisTec, who now provide the HP Simplepass application, have made an update of the scanner software for Firefox 4, for details see https://support.mozilla.com/questions/814397

  • 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

Maybe you are looking for

  • Urgent !! -Please Help -Leaving action delimits IT 0017

    Hello Gurus, At the moment when you run the Action to make an employee a leaver in HR the Action delimits Infotype 0017 Travel Privileges.  This then means that if the Travel & Expense Department need to go and view expense claims for that employee t

  • Query In Query Can I do this???

    hi every viewer, Is it possible that in reports group query i use another query in the existing query for another column e.g select t1.code,t1.detail, sum(t1.dr), sum(t1.cr), ( select sum(t1.dr)-sum(t1.cr) from t1 where t1.code = t1.code and t1.sdate

  • Move at the beginning of a view in each postback

    How to move at the beginning of a view in each postback ??

  • Reinstalling Mac OS X 10.4.4 stuck on Disc One

    Running Mac OS X 10.4.4 on wife's iMac.  Lost Install Disc 2,  computer keeps asking for Install Disc 2 and won't let me past Disc 1 ... tried reboot and holding C ... didn't work.  Anyone got another I can beg,  borrow,  buy?

  • Need a good camera

    Hi. I'm looking for a webcam with a fairly high quality picture to use with a mac pro tower. I tried using the logitech quickcam 9000 although the software is only for windows. The picture quality of the camera was very good , and it was only about 7