CASE with MIN statement?

I am trying to write a case statement that says what STAT is select E MIN (TERM)
If there are several TERMS that are both low just choose No. Want a line by ID.
Is this possible using case?

Thank you.
CREATE TABLE DAN_GR2
(ID    VARCHAR2(12),
TERM    VARCHAR2(12),
STAT VARCHAR2(12)) 

INSERT INTO DAN_GR2 (ID, TERM,STAT) VALUES ('1','5','E')
INSERT INTO DAN_GR2 (ID, TERM,STAT) VALUES ('1','2','D')
INSERT INTO DAN_GR2 (ID, TERM,STAT) VALUES ('1','9','E')
INSERT INTO DAN_GR2 (ID, TERM,STAT) VALUES ('1','5','E')
INSERT INTO DAN_GR2 (ID, TERM,STAT) VALUES ('2','1','E')
INSERT INTO DAN_GR2 (ID, TERM,STAT) VALUES ('2','10','E')
INSERT INTO DAN_GR2 (ID, TERM,STAT) VALUES ('3,'10','D')
ID      TERM     STAT
1     5     E
1     2     D
1     9     E
1     5     E
2     1     E
2     10     E
3       10      D
Here you are
ID   MIN_TERM   
1     5     
2     1
3     NULL
Use: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi

Edited by: Chloe_19 09/12/2012 18:07

Hello

So, you don't want to ignore the whole when line stat! = 'E' (that ignores the single row with id = "3"). Put the condition ' stat = 'E' in the sill of the WHERE clause ignores line, so this isn't what you want.
You want to just ignore the expression column. Put the same condition in a CASE expression that contols only this column.

Here's one way:

SELECT       id
,       MIN ( CASE
                 WHEN  stat = 'E'
              THEN     term
             END
           )          AS min_e_term
FROM      dan_gr2
GROUP BY  id
ORDER BY  id
;

Tags: Database

Similar Questions

  • What is the best way to preserve my having iPhoto library merge my pictures of girls with mine that his iMac had stopped working.

    What is the best way to preserve my iPhoto library had fusion - UN-intentionally - pictures of girls with mine as its iMac had stopped working. Some how I have about 48 000 pictures now where before I was about 11 000

    The iMac's hard drive has been deleted in tact and two weeks ago, she bought a new iMac 27' which has only the "Photos" application, but in trying to restore his iPhoto library, it gets about 24% then stops with a po - up window saying "cannot continue due to inconsistancies", that these are we don't know.

    I think using his old h/drive connected via usb to my iMac, I managed to save his library.

    On an external drive, I would like to make my backups that are up to date for a few days so that my photos need to be secured.

    1. Can I remove my iPhoto library and then re - import of my external hard drive?

    2. Can I give my daughter a copy of the "iPhoto app" and install on its new iMac and then re - import photos into iPhoto?

    More popular tips.

    Alan

    I copy the library from the back to the top first before deleting anything, in case something goes wrong. You can choose which library to open hold down the option (or alt) key key and launch of iPhoto. In the menu that appears, select "Choose Library"

    No. but you can give him the iphoto library and she can open it with Photos.

  • Sansa Clip + Question of burden (with mini USB cell phone charger)

    I have a few questions about the issue of workload:

    • is it acceptable to fresh clip + use the charger of mobile phone with mini USB socket (5v ~ 700mA), as I know, USB 2.0 specification is 5v ~ 500mA?
    • Sansa is equipped with a circuit to handle the charging process, for example the the blackout when the battery is fully charged?
    • After that several hours connected to the computer, the turn display self... is this normal? (so I have to press a button to see the screen saver and check the State of charge)

    Thanks for the answer of my question... hehhe

    You can use any charger, but be sure that it is 5V and not higher than (above will FRY your Clip).  Around 350 my and especially (even if some 500 my and above is best) is very well - the Clip will use the amperage he needs.

    Yep, you can disable the data pins and everything should be ok.  Just be sure you know what you're doing on the pins.  Many people say to be able to arrive at the same end simply by inserting the USB cable into the computer, not completely or by covering the data pins.  In addition, you can buy USB charge cables only - I have a couple of people.

    Note that when you connect to your computer, you can still read the Clip files, via the computer itself (not the music) and media playing software that is pointed and play the songs on the Clip.

  • Compare lines with the contractor ID and choose the line with Min Date rental

    Hello

    I have a scenario where I need a line with the Minimum of the Pavilion main 'p' Hire Date whenever there are multiple records with the same ID of the contractor. I need a SQL for this

    For example

    Contractor_ID name Hire_Date end_date Primary_Flag

    123 Tom 9/11/2011-9/11/2012

    123 Tom 9/12/2012-5/12/2012


    I need to score the first line of 'P '. It is an example where there are thousands of discs where I have to mark. Some cases it can be 3 or 4 files to contractor_id even where I need a 'P' flag for recording with Min Hire_Date


    Thank you
    RAM

    Hello

    If you want to ensure that only 1 row by entrepreneur is marked "P", if the lines are the same, then I suggest you do something on the ROW_NUMBER analytic function, like this:

    SELECT       contractor_number
    ,       full_name
    ,       job_title
    ,       hire_date
    ,       end_date
    ,       CASE
               WHEN  1 = ROW_NUMBER () OVER ( PARTITION BY  contractor_number
                                                    ORDER BY          hire_date
                                  ,                end_date     DESC
                                )
               THEN  'P'
           END          AS primary_flag
    FROM       contractor
    ORDER BY  contractor_number
    ,            hire_date
    ,       end_date
    ;
    

    Output:

    CONTRACTOR
       _NUMBER FULL_NAME  JOB_TITLE  HIRE_DATE  END_DATE   P
    ---------- ---------- ---------- ---------- ---------- -
       1862180 Tom        Developer  8/01/2011  11/30/2012 P
       1862180 Tom        Developer  12/01/2012 11/30/2013
       1862181 Sam        Developer  9/01/2012  9/30/2012
       1862181 Sam        Developer  9/01/2012  12/30/2012
       1862181 Sam        Developer  9/01/2012  12/30/2012 P
    
  • Object with several States and slider in the "folio" are pixelated, settings seem correct.

    I can't keep an object with several States to be rasterized text, as well as a slider which is also dithering.

    I read that you are supposed to adjust the folio, and article up to be .pdf and the cursor should have the possibility of vector chosen.

    I have not found anything to object state multi for these parameters.

    What happens is when I exit the folio to Adobe Content Viewer, only the text of these items is rasterized. All other texts to be crispy. Tested on Mini iPad and iPad retina and both are blurred.

    Is there a way to force the vector option? It seems even with the selected options it is still screening test in interactive elements.

    Thank you!

    I don't know if I missed something, but it seems to work now. Maybe the v26 option (I deleted the old folio and recreated, and it works as expected now.)

    Can you send me a link to information about the scrolling content and the position of the document? The method I used the frame was from an article of Adobe, although it could be old.

    Thanks for your help!

  • Typing a wrong URL in the URL from Firefox 31.0 bar redirects me to us.yhs4 yahoo com search that displays the LAVASOFT logo. It is not the case with any of my

    Typing a wrong URL in the URL from Firefox 31.0 bar redirects me to us.yhs4 yahoo com search that displays the LAVASOFT logo. It is not the case with any of my other browsers (IE, Chrome, Opera, Safari). So this cannot be a problem ISP as shown in all current references to Firefox.
    This problem started after I uninstalled adaware from LAVASOFT. It itself instead of uninstall. Thus, it is malware behavior while LAVASOFT is pretending to protect against malware.
    Nevertheless, I would like to know how to get rid of this annoying 404 redirect hijack. My home page is about to startpage com, my default search engine is startpage com, all references to Lavasoft and adaware have been removed by subject: config and Windows registry...
    How to get rid of this spam redirect, please?

    Click Tools > Options, then general tab

    In the home page box, type the url you want to fire fox opens by default when you start the browser.

    KhalidXpert

  • When I try to reply to a message on my Yahoo email, nothing happens when I type. This is not the case with safari.

    That's the problem. On my Yahoo email, no letters appear when I try to type a response. This is not the case with Safari.

    All of a sudden it started working again! So strange. No explanation?

    see you soon,

    Norbert

  • Yahoo mail compose page announced the Indian Railways. Same is the case with some Gmail site. For this reason, it is difficult to compose mail. I need your help to clear advertising so that I can compose mail on the blank page, cordially. Maes

    Yahoo mail is normally empty. One can type mail in the blank part of . In my case the Compose page has rail logo. because I can't type my mail. Even if there is no problem in gmail-INBO isn't the case with Gmail site "A Google approach to email" or make up may site.
    For this reason, it is difficult to compose mail on yahoo mail. I need your help to clear advertising logo so that I can compose mail on a white page, cordially. eldiablo kumar

    You can also try to install Adblock Plus with Easylist subscription and check

  • A case with a magnetic closure shut down an iPhone?

    Hello

    I have an iPhone 6 s more. I am not satisfied with its battery life. I read that a case with a magnetic closure turns off the phone when it is closed. I would like to know if anyone has such a case, and that it is the phone off to conserve battery power.

    If not then I'll have to go to some form of extended battery pack, but there will be another question.

    Thank you, in advance.

    rlmslo

    I have not heard of these cases. Beside this, turn your phone off and back on every time that you open the case a) will affect your battery life b) make you expect about minutes whenever you want to check your email. Not very practical.

    There are a lot of battery boxes, choose the one you prefer.

    Here are a few tips battery:

    http://www.IMore.com/battery-life-problems-iOS-9-heres-fix

    https://www.Apple.com/batteries/maximizing-performance/

    sues-iPhone-iPad-and-iPod-422229 http://www.idigitaltimes.com/iOS-82-Battery-Life-Problems-How-Fix-Quick-drain-is

  • Which is the * which replaces the zip codes with "United States".

    So I use the calendar for my daily schedule of the customer. Recently, I made the mistake of upgrading to OS (always a mistake with apple these days) and now have a MAJOR problem with the location field.

    Some * at apple decided to replace the postal code SUPREMELY USEFUL with 'United States', when I get an address and ap auto fills in the rest. I tried replacing it and not selecting in the dropdown list options that appears when I start typing in a speech, but it is on its own.

    Must say replacing a very specific data item for something so broad that the United States is one of the stupidest things, Apple has done recently (apple doing stupid things is unfortunately too often PJ {Post job}).

    I drove to the wrong address several times that big cities like THE have often more than a street with the same name. Get a zip code has been a great way to avoid this problem, but some Morón has decided to get rid of post code data and the access point has no option of preference to add in the zip code.

    Be sick enough Apple make these kind of nonsense that would never happened before (Ex: decide to move progress bars to 100% immediately independent to the extent of the progress are actually completed).

    Anyone know a work around? The only advice I receive from apple is to return to an older operating system (great work apple.) Train me to not trust and avoid your new operating system.  Great idea, is NOT).

    Post edited by: codr

    I know that we just spend an hour on the phone with apple care and they told us the same thing. We need these postal codes to be there so that we our sellers in the right place. missing or being late for the appointment is very professional. We need apple to fix this ASAP.

  • We could not verify your address. We could not pair your zip code with your state. Please see the bulletin.

    How to solve this "we couldn't verify your address. We could not pair your zip code with your state. Please review. » ?

    Well, the obvious answer is to make sure that the zip code is valid for the State you entered.

  • I use IMOVIE. I had to project with mini videos. I can't burn a DVD. I have DVD creator, I can't find the project. How can I do?

    I use IMOVIE. I had to project with mini videos. I can't burn a DVD. I have DVD creator during its use, I can't find the project. How can I do? I made in IMOVIE I force see where and how I can save the project

    I have an IMAC

    Hey fradel,.

    Looks like you need to export your movie, so you can burn it to a DVD using the DVD Creator Application.  Back on how to do it.

    Now I'm not sure what version of iMovie you use, but take a look at the links below for the steps to export the videos to your computer. Then you should be able to see those newly created files on your DVD Creator application.

    This first link is for the latest version of iMovie and the following link is for the previous. If you have a different version of let me know.

    iMovie (2013): export a QuickTime file
    https://support.Apple.com/kb/PH14734

    iMovie 11: export your videos in a folder from the Finder
    https://support.Apple.com/kb/PH2285

    Take care

  • every time that I connect to his screen name appears with mine and I have to choose one. How to take sound?

    My son used my pc and every time that I connect to his screen name appears with mine and I have to choose one.  How to take sound?

    Hello

    What version of Windows?
    You ask about your Windows login or a Web site?

    If you ask about Windows logon, it should work with Vista or Windows 7...

    Right click on the desktop computer > manage. In the Management Console, click on system tools > local users and groups > users, select the account else > right click > properties > OK your way out and disable the account. You will need to reactivate the account for this account to use in the future.

    Don

  • So I recently found my game Age of Mythology. The disc is very good and works, but I have not the case with the number of products to this topic. What should I do?

    So I recently found my game Age of Mythology. The disc is very good and works, but I have not the case with the number of products to this topic. What should I do?

    Hi GuyT6,

    ·         What version of the operating system is installed on the computer?

    I suggest you contact the customer assistance form help and more information.

    How and when to contact Microsoft and support Customer Service

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

  • Problem with diagram State Toolkit 1.0 - LV 8.2 upgrade to 2014

    I'm in transition a large amount of code from Labview 8.2 to 2014, and I'm having a problem with state diagrams have been added using the state diagram Toolkit V1.0.

    The figure below shows the question, Labview knows the loop and its components are associated with a state diagram, but it option to change the schema, "change the state diagram," is not available.  In Labview 8.2, which I am currently running on older machines, I would simply select "Change the state diagram" and another window of each State and arrows between States appears, allowing the mounting of the diagram.

    I think I have to install the state diagram Toolkit V1.0 software, but it is no longer available on the Web site of NOR.  There are new States transitions module I installed, but it is significantly different from the old Toolbox and does not support.  Any recommendations?

    Thank you very much
    Phil

    Good news:

    (1) SDE still works with SP1 LV2014.

    (2) I have the installer and I'm ready to send it to you. Please send me a private message with your email address.

    Be sure to support this idea.

Maybe you are looking for

  • Using Firefox 8.0.1, but welcome screen says that I do not use the latest vestion. Why?

    I've recently upgraded to Version 8.0.1 but when I launch Firefox home page tells me. You are not on the latest version of Firefox. Update today.When I open Firefox that says;"Firefox is updated.It doesn't seem to be the source of other problems, but

  • DRM permission disappear

    I got a laptop HP C727 running Vista. At about 43 digital films downloaded on it. Never gave me a problem. I decided that I needed a laptop again, stronger so I bought a HP dv7-6c95dx and upgraded windows home 7 to Windows 7 Professional. I started t

  • BIOS problem on dv9500

    I got a CTO dv9500z who owns a F32 BIOS flashed to her. This BIOS, as far as I know, was never for this laptop. When I try to update to all of the BIOS that are listed for that laptop they all, F40, 41 and 42 all say no to this computer. I also leave

  • How to create bubbles?

    I know where I can find phylacteries. When I drag the courses they are black frilled. What I am doing wrong? Thank you

  • Downgrade from win 7 to xp, why is so difficult?

    I have a piece of software for work will not be installed in win7, not even in xp upgrade mode. The answer is maybe on this forum, I don't know. Has anyone here takes a hp Pavilion elite, e9260f,. ny556aa, intel core i5-750-2, 66 ghz. 8 GB of ddr3 me