Oracle 11g - Exclude records from set where the hour column is greater than The Next CEO of Stack OverflowSQL exclude a column using SELECT * [except columnA] FROM tableA?Oracle 10g PL/SQL- Select results as update column valuesReplacing String from each row of the column in oracle sql selectuse next_day and to_date in where clauseRetrieve Last days data from TIMESTAMP(6) ColumnOracle SQL Query Where Timestamp is in Last 1 hour Using SystimestampRow to Column in Oracle 11gOracle 11g: LIMIT OFFSET on GROUPED dataOracle 11g - Columns To RowsGet Records from 'in' query list which are not present in table

RigExpert AA-35 - Interpreting The Information

Legal workarounds for testamentary trust perceived as unfair

How to delete every two lines after 3rd lines in a file contains very large number of lines?

When you upcast Blindness/Deafness, do all targets suffer the same effect?

Does soap repel water?

Is there a difference between "Fahrstuhl" and "Aufzug"

How many extra stops do monopods offer for tele photographs?

How to edit “Name” property in GCI output?

Reference request: Grassmannian and Plucker coordinates in type B, C, D

Flying from Cape Town to England and return to another province

Bartok - Syncopation (1): Meaning of notes in between Grand Staff

What flight has the highest ratio of timezone difference to flight time?

A Man With a Stainless Steel Endoskeleton (like The Terminator) Fighting Cloaked Aliens Only He Can See

Writing differences on a blackboard

What happened in Rome, when the western empire "fell"?

Easy to read palindrome checker

Domestic-to-international connection at Orlando (MCO)

Where do students learn to solve polynomial equations these days?

How did people program for Consoles with multiple CPUs?

Unclear about dynamic binding

Is there a way to save my career from absolute disaster?

How to invert MapIndexed on a ragged structure? How to construct a tree from rules?

Do I need to write [sic] when a number is less than 10 but isn't written out?

I believe this to be a fraud - hired, then asked to cash check and send cash as Bitcoin



Oracle 11g - Exclude records from set where the hour column is greater than



The Next CEO of Stack OverflowSQL exclude a column using SELECT * [except columnA] FROM tableA?Oracle 10g PL/SQL- Select results as update column valuesReplacing String from each row of the column in oracle sql selectuse next_day and to_date in where clauseRetrieve Last days data from TIMESTAMP(6) ColumnOracle SQL Query Where Timestamp is in Last 1 hour Using SystimestampRow to Column in Oracle 11gOracle 11g: LIMIT OFFSET on GROUPED dataOracle 11g - Columns To RowsGet Records from 'in' query list which are not present in table










0















Consider the following, minimal example:



SQL> select key1, key2, key3, hour from teste_jm;

KEY1 KEY2 KEY3 HOUR
---------- ---------- ---------- -----
26 992296089 1504 12:30
26 992296089 1275 13:30


I'd like to exclude the record where KEY3 is 1275, because its HOUR is greater than that of the record where KEY3 is 1504.



I tried the following, but to no success (I expected KEY4 to be 1504):



SQL> select key1, key2, key3, hour, min(key3) over (partition by key1, key2, key3 order by to_date(hour, 'HH24:MI')) key4 from teste_jm;

KEY1 KEY2 KEY3 HOUR KEY4
---------- ---------- ---------- ----- ----------
26 992296089 1275 13:30 1275
26 992296089 1504 12:30 1504


So essentially, what I'd like to do, in Oracle 11g, is to keep only the records whose hour is the earliest, for the same KEY1, KEY2 pair.



How would I do this?



EDIT: Here's a more complete example:



SQL> select * from teste_jm;

KEY1 KEY2 KEY3 HOUR
---------- ---------- ---------- -----
27 993334444 1 23:00
27 993334444 2 23:59
26 992296089 1504 12:30
26 992296089 1275 13:30


Desired output for the above:



 KEY1 KEY2 KEY3 HOUR
---------- ---------- ---------- -----
27 993334444 1 23:00
26 992296089 1504 12:30


SQLFiddle containing the sample data here.










share|improve this question




























    0















    Consider the following, minimal example:



    SQL> select key1, key2, key3, hour from teste_jm;

    KEY1 KEY2 KEY3 HOUR
    ---------- ---------- ---------- -----
    26 992296089 1504 12:30
    26 992296089 1275 13:30


    I'd like to exclude the record where KEY3 is 1275, because its HOUR is greater than that of the record where KEY3 is 1504.



    I tried the following, but to no success (I expected KEY4 to be 1504):



    SQL> select key1, key2, key3, hour, min(key3) over (partition by key1, key2, key3 order by to_date(hour, 'HH24:MI')) key4 from teste_jm;

    KEY1 KEY2 KEY3 HOUR KEY4
    ---------- ---------- ---------- ----- ----------
    26 992296089 1275 13:30 1275
    26 992296089 1504 12:30 1504


    So essentially, what I'd like to do, in Oracle 11g, is to keep only the records whose hour is the earliest, for the same KEY1, KEY2 pair.



    How would I do this?



    EDIT: Here's a more complete example:



    SQL> select * from teste_jm;

    KEY1 KEY2 KEY3 HOUR
    ---------- ---------- ---------- -----
    27 993334444 1 23:00
    27 993334444 2 23:59
    26 992296089 1504 12:30
    26 992296089 1275 13:30


    Desired output for the above:



     KEY1 KEY2 KEY3 HOUR
    ---------- ---------- ---------- -----
    27 993334444 1 23:00
    26 992296089 1504 12:30


    SQLFiddle containing the sample data here.










    share|improve this question


























      0












      0








      0








      Consider the following, minimal example:



      SQL> select key1, key2, key3, hour from teste_jm;

      KEY1 KEY2 KEY3 HOUR
      ---------- ---------- ---------- -----
      26 992296089 1504 12:30
      26 992296089 1275 13:30


      I'd like to exclude the record where KEY3 is 1275, because its HOUR is greater than that of the record where KEY3 is 1504.



      I tried the following, but to no success (I expected KEY4 to be 1504):



      SQL> select key1, key2, key3, hour, min(key3) over (partition by key1, key2, key3 order by to_date(hour, 'HH24:MI')) key4 from teste_jm;

      KEY1 KEY2 KEY3 HOUR KEY4
      ---------- ---------- ---------- ----- ----------
      26 992296089 1275 13:30 1275
      26 992296089 1504 12:30 1504


      So essentially, what I'd like to do, in Oracle 11g, is to keep only the records whose hour is the earliest, for the same KEY1, KEY2 pair.



      How would I do this?



      EDIT: Here's a more complete example:



      SQL> select * from teste_jm;

      KEY1 KEY2 KEY3 HOUR
      ---------- ---------- ---------- -----
      27 993334444 1 23:00
      27 993334444 2 23:59
      26 992296089 1504 12:30
      26 992296089 1275 13:30


      Desired output for the above:



       KEY1 KEY2 KEY3 HOUR
      ---------- ---------- ---------- -----
      27 993334444 1 23:00
      26 992296089 1504 12:30


      SQLFiddle containing the sample data here.










      share|improve this question
















      Consider the following, minimal example:



      SQL> select key1, key2, key3, hour from teste_jm;

      KEY1 KEY2 KEY3 HOUR
      ---------- ---------- ---------- -----
      26 992296089 1504 12:30
      26 992296089 1275 13:30


      I'd like to exclude the record where KEY3 is 1275, because its HOUR is greater than that of the record where KEY3 is 1504.



      I tried the following, but to no success (I expected KEY4 to be 1504):



      SQL> select key1, key2, key3, hour, min(key3) over (partition by key1, key2, key3 order by to_date(hour, 'HH24:MI')) key4 from teste_jm;

      KEY1 KEY2 KEY3 HOUR KEY4
      ---------- ---------- ---------- ----- ----------
      26 992296089 1275 13:30 1275
      26 992296089 1504 12:30 1504


      So essentially, what I'd like to do, in Oracle 11g, is to keep only the records whose hour is the earliest, for the same KEY1, KEY2 pair.



      How would I do this?



      EDIT: Here's a more complete example:



      SQL> select * from teste_jm;

      KEY1 KEY2 KEY3 HOUR
      ---------- ---------- ---------- -----
      27 993334444 1 23:00
      27 993334444 2 23:59
      26 992296089 1504 12:30
      26 992296089 1275 13:30


      Desired output for the above:



       KEY1 KEY2 KEY3 HOUR
      ---------- ---------- ---------- -----
      27 993334444 1 23:00
      26 992296089 1504 12:30


      SQLFiddle containing the sample data here.







      sql oracle11g






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 7 at 17:40







      Miguel Lopes Martins

















      asked Mar 7 at 16:41









      Miguel Lopes MartinsMiguel Lopes Martins

      157




      157






















          3 Answers
          3






          active

          oldest

          votes


















          0














          You are close but you need a subquery to filter and the right logic for the minimum:



          select key1, key2, key3, hour
          from (select key1, key2, key3, hour,
          min(to_date(hour, 'HH24:MI')) over (partition by key1) as min_hour
          from teste_jm
          ) t
          where hour = min_hour;





          share|improve this answer

























          • Seems to work, thank you. Just a small correction: "hour" is a VARCHAR2(5) column in the HH24:MI format; therefore, the subquery should contain to_date(hour, 'HH24:MI') and min(to_date(hour, 'HH24:MI')) instead of hour and min(hour) respectively. Other than that, your answer seems okay.

            – Miguel Lopes Martins
            Mar 8 at 10:00


















          0














          Why dont you just group by and get the min and I hope the above input vs o/p sample is correct so as to sync with below query



           Select KEY1, KEY2 ,min(KEY3), HOUR 
          from table group by
          KEY1, KEY2
          having HOUR=min(HOUR)





          share|improve this answer

























          • That yields... ORA-00979: not a GROUP BY expression

            – Miguel Lopes Martins
            Mar 7 at 17:32











          • check now it should work. I just saw there were multiple key3's thats y it din work

            – Himanshu Ahuja
            Mar 7 at 17:34












          • Still doesn't work. Not a GROUP BY expression. I added an SQLFiddle link to my original post so you can check.

            – Miguel Lopes Martins
            Mar 7 at 17:42


















          -1














          try to do this



          select key1, key2, key3, hour from teste_jm where hour = (select min(hour) from teste_jm);


          Uh, after your edit, Try this



          select key1, key2, key3, min(hour) OVER (PARTITION BY key1,key2) from teste_jm;





          share|improve this answer

























          • Sorry, but this doesn't produce the output I want; see the "more complete example" above, where I want 2 records to be returned. I apologize for not being clearer sooner.

            – Miguel Lopes Martins
            Mar 7 at 17:01











          • No problem. I edited my answer.

            – dazageek
            Mar 7 at 17:08











          • Hmm, your second answer is... Kinda close? I actually want to select some sort of MIN(KEY3) instead of MIN(HOUR)... Except... In order to decide what the minimum value is, I want the HOUR column to be used. Hope that makes sense.

            – Miguel Lopes Martins
            Mar 7 at 17:15











          • You just have to have a condition in having clause as those keys of min hour check my answer

            – Himanshu Ahuja
            Mar 7 at 17:26











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55048852%2foracle-11g-exclude-records-from-set-where-the-hour-column-is-greater-than%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          3 Answers
          3






          active

          oldest

          votes








          3 Answers
          3






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You are close but you need a subquery to filter and the right logic for the minimum:



          select key1, key2, key3, hour
          from (select key1, key2, key3, hour,
          min(to_date(hour, 'HH24:MI')) over (partition by key1) as min_hour
          from teste_jm
          ) t
          where hour = min_hour;





          share|improve this answer

























          • Seems to work, thank you. Just a small correction: "hour" is a VARCHAR2(5) column in the HH24:MI format; therefore, the subquery should contain to_date(hour, 'HH24:MI') and min(to_date(hour, 'HH24:MI')) instead of hour and min(hour) respectively. Other than that, your answer seems okay.

            – Miguel Lopes Martins
            Mar 8 at 10:00















          0














          You are close but you need a subquery to filter and the right logic for the minimum:



          select key1, key2, key3, hour
          from (select key1, key2, key3, hour,
          min(to_date(hour, 'HH24:MI')) over (partition by key1) as min_hour
          from teste_jm
          ) t
          where hour = min_hour;





          share|improve this answer

























          • Seems to work, thank you. Just a small correction: "hour" is a VARCHAR2(5) column in the HH24:MI format; therefore, the subquery should contain to_date(hour, 'HH24:MI') and min(to_date(hour, 'HH24:MI')) instead of hour and min(hour) respectively. Other than that, your answer seems okay.

            – Miguel Lopes Martins
            Mar 8 at 10:00













          0












          0








          0







          You are close but you need a subquery to filter and the right logic for the minimum:



          select key1, key2, key3, hour
          from (select key1, key2, key3, hour,
          min(to_date(hour, 'HH24:MI')) over (partition by key1) as min_hour
          from teste_jm
          ) t
          where hour = min_hour;





          share|improve this answer















          You are close but you need a subquery to filter and the right logic for the minimum:



          select key1, key2, key3, hour
          from (select key1, key2, key3, hour,
          min(to_date(hour, 'HH24:MI')) over (partition by key1) as min_hour
          from teste_jm
          ) t
          where hour = min_hour;






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 8 at 11:41

























          answered Mar 7 at 19:17









          Gordon LinoffGordon Linoff

          792k36316419




          792k36316419












          • Seems to work, thank you. Just a small correction: "hour" is a VARCHAR2(5) column in the HH24:MI format; therefore, the subquery should contain to_date(hour, 'HH24:MI') and min(to_date(hour, 'HH24:MI')) instead of hour and min(hour) respectively. Other than that, your answer seems okay.

            – Miguel Lopes Martins
            Mar 8 at 10:00

















          • Seems to work, thank you. Just a small correction: "hour" is a VARCHAR2(5) column in the HH24:MI format; therefore, the subquery should contain to_date(hour, 'HH24:MI') and min(to_date(hour, 'HH24:MI')) instead of hour and min(hour) respectively. Other than that, your answer seems okay.

            – Miguel Lopes Martins
            Mar 8 at 10:00
















          Seems to work, thank you. Just a small correction: "hour" is a VARCHAR2(5) column in the HH24:MI format; therefore, the subquery should contain to_date(hour, 'HH24:MI') and min(to_date(hour, 'HH24:MI')) instead of hour and min(hour) respectively. Other than that, your answer seems okay.

          – Miguel Lopes Martins
          Mar 8 at 10:00





          Seems to work, thank you. Just a small correction: "hour" is a VARCHAR2(5) column in the HH24:MI format; therefore, the subquery should contain to_date(hour, 'HH24:MI') and min(to_date(hour, 'HH24:MI')) instead of hour and min(hour) respectively. Other than that, your answer seems okay.

          – Miguel Lopes Martins
          Mar 8 at 10:00













          0














          Why dont you just group by and get the min and I hope the above input vs o/p sample is correct so as to sync with below query



           Select KEY1, KEY2 ,min(KEY3), HOUR 
          from table group by
          KEY1, KEY2
          having HOUR=min(HOUR)





          share|improve this answer

























          • That yields... ORA-00979: not a GROUP BY expression

            – Miguel Lopes Martins
            Mar 7 at 17:32











          • check now it should work. I just saw there were multiple key3's thats y it din work

            – Himanshu Ahuja
            Mar 7 at 17:34












          • Still doesn't work. Not a GROUP BY expression. I added an SQLFiddle link to my original post so you can check.

            – Miguel Lopes Martins
            Mar 7 at 17:42















          0














          Why dont you just group by and get the min and I hope the above input vs o/p sample is correct so as to sync with below query



           Select KEY1, KEY2 ,min(KEY3), HOUR 
          from table group by
          KEY1, KEY2
          having HOUR=min(HOUR)





          share|improve this answer

























          • That yields... ORA-00979: not a GROUP BY expression

            – Miguel Lopes Martins
            Mar 7 at 17:32











          • check now it should work. I just saw there were multiple key3's thats y it din work

            – Himanshu Ahuja
            Mar 7 at 17:34












          • Still doesn't work. Not a GROUP BY expression. I added an SQLFiddle link to my original post so you can check.

            – Miguel Lopes Martins
            Mar 7 at 17:42













          0












          0








          0







          Why dont you just group by and get the min and I hope the above input vs o/p sample is correct so as to sync with below query



           Select KEY1, KEY2 ,min(KEY3), HOUR 
          from table group by
          KEY1, KEY2
          having HOUR=min(HOUR)





          share|improve this answer















          Why dont you just group by and get the min and I hope the above input vs o/p sample is correct so as to sync with below query



           Select KEY1, KEY2 ,min(KEY3), HOUR 
          from table group by
          KEY1, KEY2
          having HOUR=min(HOUR)






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 7 at 18:16

























          answered Mar 7 at 17:23









          Himanshu AhujaHimanshu Ahuja

          1,0252219




          1,0252219












          • That yields... ORA-00979: not a GROUP BY expression

            – Miguel Lopes Martins
            Mar 7 at 17:32











          • check now it should work. I just saw there were multiple key3's thats y it din work

            – Himanshu Ahuja
            Mar 7 at 17:34












          • Still doesn't work. Not a GROUP BY expression. I added an SQLFiddle link to my original post so you can check.

            – Miguel Lopes Martins
            Mar 7 at 17:42

















          • That yields... ORA-00979: not a GROUP BY expression

            – Miguel Lopes Martins
            Mar 7 at 17:32











          • check now it should work. I just saw there were multiple key3's thats y it din work

            – Himanshu Ahuja
            Mar 7 at 17:34












          • Still doesn't work. Not a GROUP BY expression. I added an SQLFiddle link to my original post so you can check.

            – Miguel Lopes Martins
            Mar 7 at 17:42
















          That yields... ORA-00979: not a GROUP BY expression

          – Miguel Lopes Martins
          Mar 7 at 17:32





          That yields... ORA-00979: not a GROUP BY expression

          – Miguel Lopes Martins
          Mar 7 at 17:32













          check now it should work. I just saw there were multiple key3's thats y it din work

          – Himanshu Ahuja
          Mar 7 at 17:34






          check now it should work. I just saw there were multiple key3's thats y it din work

          – Himanshu Ahuja
          Mar 7 at 17:34














          Still doesn't work. Not a GROUP BY expression. I added an SQLFiddle link to my original post so you can check.

          – Miguel Lopes Martins
          Mar 7 at 17:42





          Still doesn't work. Not a GROUP BY expression. I added an SQLFiddle link to my original post so you can check.

          – Miguel Lopes Martins
          Mar 7 at 17:42











          -1














          try to do this



          select key1, key2, key3, hour from teste_jm where hour = (select min(hour) from teste_jm);


          Uh, after your edit, Try this



          select key1, key2, key3, min(hour) OVER (PARTITION BY key1,key2) from teste_jm;





          share|improve this answer

























          • Sorry, but this doesn't produce the output I want; see the "more complete example" above, where I want 2 records to be returned. I apologize for not being clearer sooner.

            – Miguel Lopes Martins
            Mar 7 at 17:01











          • No problem. I edited my answer.

            – dazageek
            Mar 7 at 17:08











          • Hmm, your second answer is... Kinda close? I actually want to select some sort of MIN(KEY3) instead of MIN(HOUR)... Except... In order to decide what the minimum value is, I want the HOUR column to be used. Hope that makes sense.

            – Miguel Lopes Martins
            Mar 7 at 17:15











          • You just have to have a condition in having clause as those keys of min hour check my answer

            – Himanshu Ahuja
            Mar 7 at 17:26















          -1














          try to do this



          select key1, key2, key3, hour from teste_jm where hour = (select min(hour) from teste_jm);


          Uh, after your edit, Try this



          select key1, key2, key3, min(hour) OVER (PARTITION BY key1,key2) from teste_jm;





          share|improve this answer

























          • Sorry, but this doesn't produce the output I want; see the "more complete example" above, where I want 2 records to be returned. I apologize for not being clearer sooner.

            – Miguel Lopes Martins
            Mar 7 at 17:01











          • No problem. I edited my answer.

            – dazageek
            Mar 7 at 17:08











          • Hmm, your second answer is... Kinda close? I actually want to select some sort of MIN(KEY3) instead of MIN(HOUR)... Except... In order to decide what the minimum value is, I want the HOUR column to be used. Hope that makes sense.

            – Miguel Lopes Martins
            Mar 7 at 17:15











          • You just have to have a condition in having clause as those keys of min hour check my answer

            – Himanshu Ahuja
            Mar 7 at 17:26













          -1












          -1








          -1







          try to do this



          select key1, key2, key3, hour from teste_jm where hour = (select min(hour) from teste_jm);


          Uh, after your edit, Try this



          select key1, key2, key3, min(hour) OVER (PARTITION BY key1,key2) from teste_jm;





          share|improve this answer















          try to do this



          select key1, key2, key3, hour from teste_jm where hour = (select min(hour) from teste_jm);


          Uh, after your edit, Try this



          select key1, key2, key3, min(hour) OVER (PARTITION BY key1,key2) from teste_jm;






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 7 at 17:04

























          answered Mar 7 at 16:50









          dazageekdazageek

          93




          93












          • Sorry, but this doesn't produce the output I want; see the "more complete example" above, where I want 2 records to be returned. I apologize for not being clearer sooner.

            – Miguel Lopes Martins
            Mar 7 at 17:01











          • No problem. I edited my answer.

            – dazageek
            Mar 7 at 17:08











          • Hmm, your second answer is... Kinda close? I actually want to select some sort of MIN(KEY3) instead of MIN(HOUR)... Except... In order to decide what the minimum value is, I want the HOUR column to be used. Hope that makes sense.

            – Miguel Lopes Martins
            Mar 7 at 17:15











          • You just have to have a condition in having clause as those keys of min hour check my answer

            – Himanshu Ahuja
            Mar 7 at 17:26

















          • Sorry, but this doesn't produce the output I want; see the "more complete example" above, where I want 2 records to be returned. I apologize for not being clearer sooner.

            – Miguel Lopes Martins
            Mar 7 at 17:01











          • No problem. I edited my answer.

            – dazageek
            Mar 7 at 17:08











          • Hmm, your second answer is... Kinda close? I actually want to select some sort of MIN(KEY3) instead of MIN(HOUR)... Except... In order to decide what the minimum value is, I want the HOUR column to be used. Hope that makes sense.

            – Miguel Lopes Martins
            Mar 7 at 17:15











          • You just have to have a condition in having clause as those keys of min hour check my answer

            – Himanshu Ahuja
            Mar 7 at 17:26
















          Sorry, but this doesn't produce the output I want; see the "more complete example" above, where I want 2 records to be returned. I apologize for not being clearer sooner.

          – Miguel Lopes Martins
          Mar 7 at 17:01





          Sorry, but this doesn't produce the output I want; see the "more complete example" above, where I want 2 records to be returned. I apologize for not being clearer sooner.

          – Miguel Lopes Martins
          Mar 7 at 17:01













          No problem. I edited my answer.

          – dazageek
          Mar 7 at 17:08





          No problem. I edited my answer.

          – dazageek
          Mar 7 at 17:08













          Hmm, your second answer is... Kinda close? I actually want to select some sort of MIN(KEY3) instead of MIN(HOUR)... Except... In order to decide what the minimum value is, I want the HOUR column to be used. Hope that makes sense.

          – Miguel Lopes Martins
          Mar 7 at 17:15





          Hmm, your second answer is... Kinda close? I actually want to select some sort of MIN(KEY3) instead of MIN(HOUR)... Except... In order to decide what the minimum value is, I want the HOUR column to be used. Hope that makes sense.

          – Miguel Lopes Martins
          Mar 7 at 17:15













          You just have to have a condition in having clause as those keys of min hour check my answer

          – Himanshu Ahuja
          Mar 7 at 17:26





          You just have to have a condition in having clause as those keys of min hour check my answer

          – Himanshu Ahuja
          Mar 7 at 17:26

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55048852%2foracle-11g-exclude-records-from-set-where-the-hour-column-is-greater-than%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

          Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

          Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved