Choose a value for max, but with restrictions?

First of all: I'm a noob-SQL...

I saw, that there is a similar question below a few threads, but it does not.

I have two tables.

1 CASE

2. STATE OF PLAY

STATUS columns:

STATUSID CASEID STATUS

1         1       01

2         1       02

3         2       01

4         3       01

5         1       03

6         2       02

7         4       01

...


Columns of CASES:

CASEID BEGINDATE

1 15/03/2014

2 07/04/2014

3 21/04/2014

4 03/05/2014

...


Now, I want to select all the cases that have the maximum status 02

Not the case who are only in status 01 and also not the case which in addition have the status 03

With:

Select caseid, max (status)

status

Caseid group;

I get max-status of all cases

With:

Select c.caseid, c.begindate, s.status

case c, s status

where c.caseid = s.caseid;

I get all the information I need, but not selected on the case with max-status

With:

Select c.caseid, c.begindate, s.status

case c, s status

where c.caseid =)

Select caseid, max (status)

status

Group caseid );

Does not work, because the subselect statement has many values...

I have no idea how to make the selection of columns with only maxstatus 01



Select caseid

status

Caseid group

After max (status) = '02';

Tags: Database

Similar Questions

  • The default value for a property with data of type boolean

    Hi all

    Is it a system preference setting, where the default value for a property with data of type boolean can be a Virgin? I want to keep the value by default in a vacuum, but every time I save the property even after empty selection, the default value changes to FALSE.

    Capture.JPG

    In this case Boolean doesn't help you, you mayneed to create a chain of ownership and have true/false / "" as your list of values

  • Setting by exporting the default value for Max in Quality program

    Hi Zac,

    I'm trying to find a way to define a default value for the 'Maximum use rendered quality' box located on the dialog window export settings. Is it possible to programmatically set a value for this box (maybe in the call to exSDKGenerateDefaultParams)? Or would a value 'default' for this box be treated by creating a "Preset"?

    Thank you
    Josh

    It is the exporter to use the setting provided by the host in exDoExportRec.maximumRenderQuality.  The exporter must define SequenceRender_ParamsRec.inRenderQuality and inDeinterlaceQuality to kPrRenderQuality_Max, if the value.

    Zac

  • How can you specify the default value for the undefined array elements

    According to aid LV, the tables have two default values, the normal default value and the default value for the undefined array elements.

    I assume that there must be a way to specify the default value for later, but I can't find it anywhere.  Any ideas?

    I know that you can drag the item out of the table container.  Change the default value on this scalar element.  Then drag the item in table tank.

  • Is there a default value for the color management in PSE10? Beautiful photos from iPhoto, but blur with elements. I need help with this before as I consider that the upgrade to PSE13 and beyond.

    Is there a default value for the color management in PSE10? Beautiful photos from iPhoto, but blur with elements. I need help with this before as I consider that the upgrade to PSE13 and beyond.

    Printing which forms an angle seems ok, but one that is horizontally seems faded, incomplete.

    I was wondering if I saved a layer somewhere and set it as a default value.

    If you group the layers, you will be left with a single layer, thus spreading your concern.

    Suggest that you do the following:

    1. Make sure you have the latest drivers for your printers
    2. Reset the default preferences.

    Hold the Alt, Ctrl + Shift keys when you click the icon to open the items. When asked if you want to delete the settings file, say Yes.

    Items nearby and let regenerate the file.

  • How to find the first max value for each item

    Hello

    I have the me_result of the table as below,

    SELECT * FROM me_result;

    ID     ||| ELITE     ||||||||||| FREQ_ITEM | COMBINED_STR | SUP
    1     ||; 1; 10; 2; 3; 4; 5; 7; 8. 1     ||||||||||||||; 1; 10; 2; 3; 4; 5; 7; 8 ||| 2
    2     ||; 1; 10; 2; 3; 4; 5; 7; 8. 2     ||||||||||||||; 1; 10; 2; 3; 4; 5; 7; 8 ||| 2
    3     ||; 1; 10; 2; 3; 4; 5; 7; 8. 3     ||||||||||||||; 1; 10; 2; 3; 4; 5; 7; 8 ||| 2
    4     ||; 1; 10; 2; 3; 4; 5; 7; 8. 4     ||||||||||||||; 1; 10; 2; 3; 4; 5; 7; 8 ||| 2
    5     ||; 1; 10; 2; 3; 4; 5; 7; 8. 5     ||||||||||||||; 1; 10; 2; 3; 4; 5; 7; 8 ||| 2
    6     ||; 10; 2; 3; 4; 5; 8; 9. 1     ||||||||||||||; 10; 2; 3; 4; 5; 8; 9; 1 ||| 1
    7     ||; 10; 2; 3; 4; 5; 8; 9. 2     ||||||||||||||; 10; 2; 3; 4; 5; 8; 9 ||| 2
    8     ||; 10; 2; 3; 4; 5; 8; 9. 3     ||||||||||||||; 10; 2; 3; 4; 5; 8; 9 ||| 2
    9     ||; 10; 2; 3; 4; 5; 8; 9. 4     ||||||||||||||; 10; 2; 3; 4; 5; 8; 9 ||| 2
    10     ||; 10; 2; 3; 4; 5; 8; 9. 5     ||||||||||||||; 10; 2; 3; 4; 5; 8; 9 ||| 2


    I need to find the first COMBINED_STR max for each element of the ELITE,
    I mean, max value is the max REGEXP_COUNT (combined_str,' ;')))

    really, I try to write down, but I had a lot of values for each ELITE and I need only the first, that
    SELECT * from me_result
    WHERE (ELITE, REGEXP_COUNT (combined_str,' ;')))) IN
    (SELECT ELITE, MAX (REGEXP_COUNT (combined_str,' ;'))))) ME_RESULT ELITE GROUP);

    I need the result to be as below.

    1; 1; 10; 2; 3; 4; 5; 7; 8-1; 1; 10; 2; 3; 4; 5; 7; : p
    6; 10; 2; 3; 4; 5; 8; 9 1; 10; 2; 3; 4; 5; 8; 9; 1 1

    any help please,.

    Published by: user11309581 on July 10, 2011 22:03

    Can be

    with t as
    (select 1     ID, ';1;10;2;3;4;5;7;8'     ELITE, 1     FREQ_ITEM, ';1;10;2;3;4;5;7;8' COMBINED_STR, 2 SUP from dual union all
    select 2     ,';1;10;2;3;4;5;7;8'     ,2     ,';1;10;2;3;4;5;7;8'     ,2 from dual union all
    select 3     ,';1;10;2;3;4;5;7;8'     ,3     ,';1;10;2;3;4;5;7;8'     ,2 from dual union all
    select 4     ,';1;10;2;3;4;5;7;8'     ,4     ,';1;10;2;3;4;5;7;8'     ,2 from dual union all
    select 5     ,';1;10;2;3;4;5;7;8'     ,5     ,';1;10;2;3;4;5;7;8'     ,2 from dual union all
    select 6     ,';10;2;3;4;5;8;9'     ,1     ,';10;2;3;4;5;8;9;1'     ,1 from dual union all
    select 7     ,';10;2;3;4;5;8;9'     ,2     ,';10;2;3;4;5;8;9'     ,2 from dual union all
    select 8     ,';10;2;3;4;5;8;9'     ,3     ,';10;2;3;4;5;8;9'     ,2 from dual union all
    select 9     ,';10;2;3;4;5;8;9'      ,4     ,';10;2;3;4;5;8;9'     ,2 from dual union all
    select 10     ,';10;2;3;4;5;8;9'     ,5     ,';10;2;3;4;5;8;9'     ,2 from dual
    )
    select ID,ELITE,FREQ_ITEM,COMBINED_STR,SUP
    from (
      SELECT ID,ELITE,FREQ_ITEM,COMBINED_STR,SUP, ROW_NUMBER() over (PARTITION BY ELITE order by id) RN
      FROM t
      WHERE (ELITE,REGEXP_COUNT(combined_str,';')) IN
        (SELECT ELITE,MAX(REGEXP_COUNT(combined_str,';')) FROM t GROUP BY ELITE)
    ) where RN=1
    order by id
    
    ID                     ELITE             FREQ_ITEM              COMBINED_STR      SUP
    ---------------------- ----------------- ---------------------- ----------------- ----------------------
    1                      ;1;10;2;3;4;5;7;8 1                      ;1;10;2;3;4;5;7;8 2
    6                      ;10;2;3;4;5;8;9   1                      ;10;2;3;4;5;8;9;1 1     
    
  • Can query serial port with NI MAX, but does not work in Labview

    I'm controlling a 488 Sapphire consistent with labview. It is connected by a series of converter USB in the computer. I can communicate with a device using NI MAX, but when I try to run the vi (attached), he works for multiple queries, but evetually returns a null character, after which I can no longer communicate with the port. If I then go into the NI MAX interface, whenever I try to read it give "VISA: (Hex 0xBFFF0015) timeout expired before the operation ended" error message. There are also several queriess of the manual of the instrument which do not seem to work at all (with or without MAX) and always returns a null character. Any help is appreciated. I'm definitely a novice with the communication of the device. Thank you.

    Usually a problem with the stop character.

    And you send-r and no CarriageReturn.

  • Max and Min value for each column

    Hello!

    Can someone help me to change my. VI? I want to get the Min and Max value for each column in the table in the appendices. Then I need to create two tables 1 d - the first with the min and the second with the max value.

    I've already solved the problem the solution is below

  • How to choose the value of a string are numeric together and words of letters (for example, TEST)

    Hi all

    How to choose the value of a string are letters (for example, TEST) and all numeric...

    for example
    TEST 123456
    TEST 34567
    123456 ABCD
    1234 TEST
    TESTING 12345
    TEST 1@234$
    YOUR T 123456

    I want the results of the query as below.
    TEST 123456
    TEST 34567

    And I tried to use regexp_like in this case but without success. See the code below.
    SELECT * FROM TABLE WHERE regexp_like (Description, ' [TEST] % & [[: digit:]] + $');

    How can I do this, please answer.

    Thank you

    WF

    If you want to return only the rows that contain the string 'TEST', followed by zero or more space characters, followed by one or more digits?

    How about this:

    SELECT *.

    FROM my_table

    WHERE REGEXP_LIKE(description,'^TEST\s*\d+$')

  • When you choose a webcam for use with host character, should what features I look for?

    When you choose a webcam for use with host character, should what features I look for in the webcam? For example, choose the one that captures full HD (1080 p)? Or any webcam will work? I just want to be able to make the motion capture process as easy as possible, so I think I must look over the webcam plug before you buy.

    Any webcam should work, but a higher resolution can improve the accuracy of tracking. Adequate/same lighting on your face is too important.

  • Update a record of ORM, but with empty value

    Hi all, excuse my poor English and my level of coldfusion poor

    I have some problems to update the data with ORM objects.

    (1) I have an object of customer with a task property (many-to-one relationships)
    (2) I have a job object (a list of works)

    When I update a client with customerOBJ.setjob (jobOBJ); It is ok

    But when I can't seem to restore an empty value for the job.

    When I try this:

    customerOBJ.setJob (), I have an error because the settings is not a type of employment

    You have some information about this?

    Thanks in advance.

    Hi friend

    This allows to obtain a value zero: javacast("null",'"")

    That is why to delete the value:

    customerOBJ.setJob (javacast("null",""));

    That should make you well. If you use it in a few places, you can create yourself a function:

    Then use:

    customerOBJ.setJob (null);

  • Import of CSV with loop value FOR

    Good afternoon

    I'm new to LabView and trying to write a VI that will eventually run a set of calculations on a set of data with millions of data points. I want the VI to count the number of data imported points of the. As they are written to a CSV file array. The number of points eventually will help me determine the behavior of the end of my calculations, it is not optional.

    I have trouble getting the file to read each successive line. The value 'for the iterations of the loop"feeds into the 'start reading Offset' «Worksheet File.vi reading» My intention was that this would result in a new line being read in the table with each iteration of the loop. What I get is the first value read over and over again in the first row of the table. Any ideas?

    Thanks for your time and help,

    Wes

    JWTyler wrote:

    I read it one line at a time so that the iteration of the loop is incremented at each line, to give me the size of the sample.

    Is there a better way to count how many points is imported? I could not find another way...

    There is a beautiful VI called "Table size" which will also do for you.

  • I bought Halo 2 for Vista, but who like OS Windows XP Pro, just can't launch the startup.exe, I search the community, there is a rumor that it won't work even with the patch. Can someone help, please?

    I bought Halo 2 for Vista, but who like OS Windows XP Pro, just can't launch the startup.exe, I search the community, there is a rumor that it won't work even with the patch. Can someone help, please?

    Unfortunately, Halo 2 does support Windows Vista and more.  Windows XP is not supported.  There may be 3 party hacks that can make it work, but they are not taken in charge and potentially dangerous.

    Paul Smith - MVP for Windows desktop experience... I crawled off NNTP - for now. Detachment Aldershot, United Kingdom. On the internet at windowsresource.net and dasmirnov.net. Please post back to let us know what works and what does not. :-)

  • I have a cd for windows xp with sp3 but I lost my product key

    I have a cd for windows xp with sp3 but I lost my product key and there is no keys on my computer

    Is XP still installed and running?

    If so, then use Belarc Advisor to find the key - www.belarc.com

  • BlackBerry Z10 well defined, I can't get the phone to ring and vibrate as the default value for all calls. I can put individual contacts, but I want to ring and vibrate for all.

    Although the value, I can not phone ring and vibrate as the default value for all calls. I can put individual to vibrate and ring contacts and it works but I want as the default for all incoming calls. Any help would be appreciated, thanks

    Sorry, I found the answer in the manual

    "Change your ringtone, sounds or alerts.

    GoTo settings\notifications to the bottom of the screen select application\phone

    You can activate vibrate out there, put the ringer default etc.

Maybe you are looking for