Need to get Max Value day in a table with hourly data of SQL

I have a table "tmp" with these columns:

ID, date, time, value

I want to get the 'time' when 'value' max is reached in each 'day '.

the query:

"SELECT id, day, hour, max (value) from group tmp by id, date, time"
does not return the desired lines.

You have an idea to get what I want?

Maybe this:

with tmp as
( select 1 id, trunc(sysdate) day, 10 hour, 100 value from dual union all
  select 2 id, trunc(sysdate) day, 11 hour, 110 value from dual union all
  select 3 id, trunc(sysdate) day, 12 hour, 120 value from dual union all
  select 4 id, trunc(sysdate) day, 13 hour, 130 value from dual union all
  select 5 id, trunc(sysdate-1) day, 10 hour, 100 value from dual union all
  select 6 id, trunc(sysdate-1) day, 11 hour, 90 value from dual union all
  select 7 id, trunc(sysdate-1) day, 12 hour, 150 value from dual union all
  select 8 id, trunc(sysdate-1) day, 13 hour, 100 value from dual )
Select ID, Day, Hour, Value
From Tmp
Where (Day, Value) IN (
Select Day, Max(Value)
From Tmp
Group by Day)

Results:

        ID DAY             HOUR      VALUE
---------- --------- ---------- ----------
         7 08-DEC-08         12        150
         4 09-DEC-08         13        130

2 rows selected.

Kind regards
Miguel

Tags: Database

Similar Questions

  • Best way to generate a record per day from a table with the dates of the FEP/exp

    Hello

    A table equipped with various attributes and a date of eff and exp. for example Attributeto, 05/01/2012, 16/05/2012

    We want to create another table in this table for a record per day. for example 16 documents.

    What is the best way to achieve this in OWB?

    Thank you

    Assuming that you have a calendar table, then you can reach your rate table corresponding to the date table schedule between the table rates start date and end date.

    Something like:

    Select a.rate, rate_table b., calendar_table b.
    where b. between a.start_date and a.end_date

    should translate easily into a join of two tables in OWB?

    Concerning
    User909022

  • public function get max value of column 3

    Hello world

    How can I determine the max value of 3 columns in ths same record

    Thank you

    user222 wrote:
    Hello world

    How can I determine the max value of 3 columns in ths same record

    Thank you

    When everything has failed, read the Fine Manual

    http://docs.Oracle.com/CD/E11882_01/server.112/e26088/functions069.htm#SQLRF00645

    Handle: user222
    Status level: Rookie (10)
    Join date: April 18, 2009
    Messages total: 301
    Total Questions: 130 (89 pending)

    Why so many unanswered questions?

  • Need help getting A value in My App using xml/php http request

    I know that maybe this isn't the place to ask questions about php, but I thought that people may have encountered a similar problem and I'm getting desperate basically my application's data is stored in a mysql database table, and what I have to do is to get the value of auto increment of this table in my application via an http request. I'm doing a php file that gets this value and displays this value in the xml format, but I'm terrible at creating php to do such things and just get the constant errors. Can someone take a look at this and help me to tweak it so it does what I want it please? The table in question is called links and the line/field/column in the table I'm after is called linkid. This is the next value of auto-increment this line printed in xml format, that's what I want. Here is the php so far:-

    <?php 
    header("Content-type: text/xml"); 
    $host = ""; 
    $user = ""; 
    $pass = ""; 
    $database = ""; 
    $linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host."); 
    mysql_select_db($database, $linkID) or die("Could not find database."); 
    $tablename   = "links";
    $next_increment  = 0;
    $qShowStatus   = "SHOW TABLE STATUS LIKE '$tablename'";
    $qShowStatusResult  = mysql_query($qShowStatus) or die ( "Query failed: " . mysql_error() . "<br/>" . $qShowStatus );
    $row = mysql_fetch_assoc($qShowStatusResult);
    $next_increment = $row['Auto_increment'];
    echo "next increment number: [$next_increment]"; 
    ?>
    

    Hello

    step 1. the customer wants to add a new record. and sends a request for a new record

    step 2. the server adds a new record in the database (now its Blanck) and returns its ID number

    step 3.  the customer has now has an appropriate identification number and use it to add a new object to the table

    step 4. the customer with a registration ID and the new data for this "empty folder" is an update not an insert.

    step 5. You now have the table and database synchronization.

    David.

  • Get the MAX value of dimension 2 table

    I have a little trouble to find a value MAX (or MIN) of the second dimension in a 2-dimensional array. I do a query and the first dimension is the column name, the second is the values. I'm coming out of the MAX value of the column in the second dimension. ArrayMax said "the array passed cannot contain more than one dimension."

    Any ideas? I'm sure that this is possible.

    MaxValue = ArrayMax (QueryName ["FieldName"]);

    or Q of Q.

  • How to get the value of column d/e with combinations of 3 columns?

    Hi all

    create the table dup_tab

    as

    Select 'AB100' donnees_1, data_2 ' 100 ', 'NN' data_3 data_4 ' 12345' double

    Union of all the

    Select 'AB100' donnees_1, data_2 ' 100 ', 'NN' data_3 data_4 ' 12346' double

    Union of all the

    Select 'AB100' donnees_1, data_2 ' 100 ', 'NN' data_3 data_4 ' 12347' double

    Union of all the

    Select 'AB200' donnees_1, data_2 ' 200 ', 'BB' data_3 data_4 ' 11111' double

    Union of all the

    Select donnees_1 'AB101', '101' data_2, data_3 'NB', '1234' double data_4

    Union of all the

    Select '1235' data_4, data_3 'NB', data_2 '101', 'AB101' donnees_1 double;

    I suspect the data as below, donnees_1,data_2,data_3 (a values) but d/f data_4 , I need to get these lines only please help me how to write a query on this

    DONNEES_1DATA_2DATA_3DATA_4
    AB100100NN12345
    AB100100NN12346
    AB100100NN12347
    AB200200BB11111
    AB101101NB.1234
    AB101101NB.1235

    In my table, I have to find with data of above combinations

    Given expected o/p

    DONNEES_1DATA_2DATA_3DATA_4
    AB100100NN12345
    AB100100NN12346
    AB100100NN12347

    Thank you

    Post edited by: Rajesh123 added extra test cases

    Hello

    Well, looking at the labels that you created for your question you have "Duplicate record".

    ...

    I suspect the data as below, donnees_1, data_2, data_3 (has the same values), but d/f data_4 , I need to get these lines only please help me how to write a query on this

    DONNEES_1 DATA_2 DATA_3 DATA_4
    AB100 100 NN 12345
    AB100 100 NN 12.4 K
    AB100 100 NN 12347
    AB200 200 BB 11111
    AB101 101 NB. 1234
    AB101 101 NB. 1235

    If you want to show the duplicated records, try the following:

    WITH t AS
      ( SELECT 'AB100' data_1, '100' data_2, 'NN' data_3 ,'12345' data_4 FROM dual
      UNION ALL
      SELECT 'AB100' data_1, '100' data_2, 'NN' data_3 ,'12346' data_4 FROM dual
      UNION ALL
      SELECT 'AB100' data_1, '100' data_2, 'NN' data_3 ,'12347' data_4 FROM dual
      UNION ALL
      SELECT 'AB200' data_1, '200' data_2, 'BB' data_3 ,'11111' data_4 FROM dual
      UNION ALL
      SELECT 'AB101' data_1, '101' data_2, 'NB' data_3 ,'1234' data_4 FROM dual
      UNION ALL
      SELECT 'AB101' data_1, '101' data_2, 'NB' data_3 ,'1235' data_4 FROM dual
      )
    SELECT *
    FROM
      (SELECT data_1,
        data_2,
        data_3,
        COUNT(*) over (partition BY data_1,data_2,data_3) cnt
      FROM t
      )
    WHERE cnt > 1
    
  • How to get the value of row current table when press the button submit

    Hello

    I want to get the current value of the SuccessionPlanId line which is part of the column in a table that is advanced.

    I created a (created using customization, from action through CO) button in the table as column, so each line with a single key, if I press the button of the first line means so I want to extract the first line SuccessionPlanId and if it's the 3rd way so I want to get the value of the value of the third row.

    How in the post of controller?

    Please answer soon, its urgency.

    Thanks in advance,
    SAN

    OK, need to go with a delicate way,

    1.) create a new table with Jdeveloper and there shud be a replica of the room once except the button submit newly added, pls note button type shud be present the type of button.

    2.) hide the existing table area and create a new stacklayoutbean.

    (3.) this stacklayout bean will have the property to extend, you give the full path of the new custom of advanced table box.

    Now you should be able to get the reference of the line during the click on the "submit" button

  • Get unique values from an xml table

    I have an xml file and I would like to create a table of all the unique values of one of its nodes.

    The xml file is called pntxml and the node is pntxml.row.Category where the category is where I would like to create a table of all the unique values.

    I was working through this and would first create an array of all the values in the category in iterating through the xml and pushing these values in a separate table.  When I try to push each entry in a table I get an error or

    TypeError: Error #1009: cannot access a property or method of a null object reference.
    at NAPA_fla::MainTimeline/sortXml()

    var catArray:Array;
    
    function sortXml(event:Event):void{
    for (var i:int = 0; i< pntxml.row.length(); i++){
         tmpCat=pntxml.row[i].Category;
         trace(tmpCat);
            catArray.push(tmpCat);           
    }
    }
    

    Anyone has a suggestion for the best way to get at this problem?

    Thanks in advance,

    Josh

    Your catArray does not exist because you said only she, you have not created an instance of this...

    var catArray:Array = new Array();

  • How to get the value of the point messagetextInput with attr 'secret' to the value 'true '.

    Hi all
    I create a messagetextInput item and set its 'secrets' attribute to "true".
    When I want to get its value to help
    OAMessageTextInputBean = newPwdBean1
    (OAMessageTextInputBean) webBean.findChildRecursive ("NewPwd1");
    newPwd1 = (String) newPwdBean1.getValue (pageContext);

    It returns null.

    Could someone tell me please how to get its value?

    I did the same to help
    Password String = (String) pageContext.getParameter ("");

    Thank you

  • Need to create a new line in the table with the same data as the primary key, but new PK

    Hello gurus,

    I have a table with a column as a primary key, I need to create a new row in the table, but with the same data in one of the lines, but with different primary keys, focus a double row with key primary diferent...

    Any ideas of how it can be done without much complication?

    Thanks in advance for your answer.

    Agress,
    Karim idrissi

    user9970447 wrote:
    Hello gurus,

    I have a table with a column as a primary key, I need to create a new row in the table, but with the same data in one of the lines, but with different primary keys, focus a double row with key primary diferent...

    Any ideas of how it can be done without much complication?

    Thanks in advance for your answer.

    Agress,
    Karim idrissi

    something like

    insert into mytable values ('literal for new pk',
                                           select non-pk-1,
                                                    non-pk-2,
                                                    non-pk-n
                                           from mytable
                                           where pk-col = 'literal for existing pk')
    
  • brand value in the time table with colors according to the selected employee

    Hello
    My question is
    I created the time table for a class for a bit longer want to filter to the time table used.

    for example. If I select the emp_id he's from, select the list then this period of teaching should be highlighted time table.
    Please can u help me.

    the table name is:-Time_Table
    the columns are:-

    EMP_ID
    CLASS_ID
    SECTION
    SUBJECT_ID
    PERIOD_NO
    DAY
    DATE


    Thank you
    Nisha

    Published by: Nisha Rani on September 3, 2009 02:57

    Published by: Nisha Rani on September 3, 2009 23:08

    Hi Nisha,

    Try this:

    SELECT
    DY,
    MIN(CASE WHEN LEC_NO = '1' THEN
    CASE WHEN EMP_ID = :P1_EMP_ID THEN '
    ' || SUBJECT_ID || '-' ||emp_id || '
    ' ELSE '
    ' || SUBJECT_ID || '-' ||emp_id || '
    ' END ELSE NULL END) PERIOD1, MIN(CASE WHEN LEC_NO = '2' THEN CASE WHEN EMP_ID = :P1_EMP_ID THEN '
    ' || SUBJECT_ID || '-' ||emp_id || '
    ' ELSE '
    ' || SUBJECT_ID || '-' ||emp_id || '
    ' END ELSE NULL END) PERIOD2, MIN(CASE WHEN LEC_NO = '3' THEN CASE WHEN EMP_ID = :P1_EMP_ID THEN '
    ' || SUBJECT_ID || '-' ||emp_id || '
    ' ELSE '
    ' || SUBJECT_ID || '-' ||emp_id || '
    ' END ELSE NULL END) PERIOD3, MIN(CASE WHEN LEC_NO = '4' THEN CASE WHEN EMP_ID = :P1_EMP_ID THEN '
    ' || SUBJECT_ID || '-' ||emp_id || '
    ' ELSE '
    ' || SUBJECT_ID || '-' ||emp_id || '
    ' END ELSE NULL END) PERIOD4, MIN(CASE WHEN LEC_NO = '5' THEN CASE WHEN EMP_ID = :P1_EMP_ID THEN '
    ' || SUBJECT_ID || '-' ||emp_id || '
    ' ELSE '
    ' || SUBJECT_ID || '-' ||emp_id || '
    ' END ELSE NULL END) PERIOD5, MIN(CASE WHEN LEC_NO = '6' THEN CASE WHEN EMP_ID = :P1_EMP_ID THEN '
    ' || SUBJECT_ID || '-' ||emp_id || '
    ' ELSE '
    ' || SUBJECT_ID || '-' ||emp_id || '
    ' END ELSE NULL END) PERIOD6, MIN(CASE WHEN LEC_NO = '7' THEN CASE WHEN EMP_ID = :P1_EMP_ID THEN '
    ' || SUBJECT_ID || '-' ||emp_id || '
    ' ELSE '
    ' || SUBJECT_ID || '-' ||emp_id || '
    ' END ELSE NULL END) PERIOD7 FROM TM_TEACHER_LEC_DETAIL WHERE CLASS_ID = :P1_CLASS_ID and SECTION = :P1_SECTION GROUP BY DY order by dy

    As I do not have the structure of your table or any data, I can't test this. Let me know if it works for you

    Andy

  • Need to get a value using a checkbox

    Hello

    I have a page of report I want to allow a user to report ignored using a process of calling a procedure. My problem that I face is the old value of the view to pass to the procedure. We want to compare the old value of the new to make sure that users do not walk on the other. The default value in this case is 'n'. I could hard-code it, but will not cut since the other mistake that we will raise, it is it must be a "n" to deal with the update.

    My question is this: How can I get the old value of the view?

    Here's my process in the apex page:

    DECLARE
    number of hq_item_ignored;
    old_flg varchar2 (9);
    BEGIN
    because me in 1.apex_application.g_f02.count
    loop
    hq_item_ignored: = to_number (apex_application.g_f02 (i));
    old_flg: = I HAVE TRIED SEVERAL SELECT STATEMENTS WITH NO LUCK
    end loop;
    --
    because me in 1.apex_application.g_f02.count
    loop
    HQ_ITEM_NOMEN_PKG. () UPD_IGNORED_FLG
    P_HQ_ITEM_NOMEN_NBR = > apex_application.g_f02 (i),
    p_old_ignore_flg = > old_flg,
    p_new_ignore_flg = > 'Y ',.
    p_mod_ut_user_nbr = >: P0_UT_USER_NBR
    );
    end loop;
    end;


    Thanks for any help you can offer!
    Steve

    Published by: Smitty on October 22, 2008 09:40

    Hello

    OK - don't know if you pasted in the complete code. The first block does not define old_flg at all and you can use hq_item_ignored in your P_HQ_ITEM_NOMEN_NBR setting.

    In the second block, you assign a value to a variable using the INTO statement:

    select ignored_flg INTO old_flg from hq_item_nomen_exception_view where hq_item_nomen_nbr = hq_item_ignored;
    

    Andy

  • get the value of the sysdate in 24-hour format time

    Hi all

    How can I get sysdate in 24-hour format time value (the result should be the only number, not the varchar value)?

    Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production

    PL/SQL Release 11.2.0.1.0 - Production

    "CORE 11.2.0.1.0 Production."

    AMT for Linux: Version 11.2.0.1.0 - Production

    NLSRTL Version 11.2.0.1.0 - Production

    Select to_number (to_char (sysdate, 'HH24')) of double;

  • How to get the value of an af:Table SelectOneChoice

    V11.1.2.4.0 - JSF JDeveloper

    Greetings,

    Im having a problem getting a column value that is an object of a select choice.

    This isn't a common problem, as I actually did something that others so please follow my problem

    Description and if you have questions/answers please answer below.

    I create a database view that returns me 3 columns, say TestValue TestCode, TestDescription.

    I added an extra temporally column in my OV and called Temp.

    I drag / drop my OV, remove value Temp and its position of the column, I drag / drop a LOV, who comes from a different view.

    that shows me the doctor name & first name and identification number of the back doctor select a value of choice.

    I'm using a function that go through the iterator, gets the lines and save them in the database (no matter how).

    The problem is my selectonechoice, are not row.bindings.DoctorId.InputValue, but the links. DoctorId.InputValue instead, so I can retrieve value selectonechoice of the current line.

    Then when my loop is finished and insert rows in my database, id of the doctor of the line everyone is the same as the binding do not change through the loop.

    I don't know how to add value to the current line select only one option to use the correct value to each loop of the line.

    Here is my loop function:

            DCBindingContainer bc = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
            DCIteratorBinding iterator = bc.findIteratorBinding("ExaminationsIterator");
            DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    
    
             RowSetIterator rsi = iterator.getRowSetIterator();  
             int i=0;
             
            OperationBinding save_exams = bindings.getOperationBinding("SAVE_EXAMINATION");
            OperationBinding save_exams_commit = bindings.getOperationBinding("SAVE_EXAMINATION_COMMIT");
               
            try{
             while(i < rsi.getRowCount()){
                 
                 Row r = iterator.getCurrentRow();
                                 
                 save_exams.getParamsMap().put("CodeTest", r.getAttribute("CodeTest"));
                 save_exams.getParamsMap().put("Dates", r.getAttribute("Dates"));   
                 save_exams.getParamsMap().put("CodeId", orderid.getValue());   
                 save_exams.getParamsMap().put("Times", r.getAttribute("Times"));    
                 save_exams.getParamsMap().put("DoctorId", resolveExpression("#{bindings.DoctorId.attributeValue}").toString()); 
                 save_exams.getParamsMap().put("IdPatients", patientid.getValue());   
                 save_exams.execute();
                 rsi.next();
                 i++;
             }
            
                save_exams_commit.execute();
    

    I get the connection id of the current doctor and the value of the rows no.

    Can you help me on this please?

    I created a work around solution, until an expert that I come with a more advanced solution.

    (1) I add a LOV at the id of the doctor on the view target object.

    (2) on the duration, I fill my view of database

    3) go through all my DB view iterator lines

    (4) appends each line on the View object target (missing id of the doctor, because I want it to be on common language runtime) & commit lines

    (5) after the loop ends and the target object from view show me results from the view of DB, I choose the runtime id of the doctor and commit the changes if

    the new lines, with the new update will be finally filled to the database.

    I hope this helps if anyone has a similar task.

    Please let me know if you find a more direct solution, this work with 2 tables to fill 1.

  • Get the Max values and average of the different cycles in the single channel

    Hello

    I'm trying to get the Max values and average of the single channel that has different cycles it contains. I tried to use commands such as Chnclasspeak3 and chnpeakfind, but they were not useful for me. What I need is the Max values and average of the different cycles numbers saved in the data channel.

    Exampld if the string contains 5 numbers of repetitive cycles, then we must find the maximum values and the average of these 5 cycles in the single channel. Attached reference data. This is the .raw file and I have the plugin for it to use in diadem 11.1.

    Kind regards

    X. Ignatius

    Hello, Ignatius,.

    Sorry, it took some time to provide a replacement based on the script for the function. Please take a look at the attached script. I changed the script to use my function if the tiara-version is less than 12. My script function is not as fast and more stable than the implementation of tiara, but for now, it does the job

    Andreas

Maybe you are looking for

  • My 5s iPhone was stolen 3 weeks ago and earlier, he went online

    SO he stole 3 weeks ago, and the second that I got 'lost' mode, it has been disconnected. He didn't have a password on it(stupid me). I then immediately put it in mode 'Clear data' because I didn't want to wait with the thought of a stranger looking

  • Basis of LabWindows/CVI 9.0 connecting winspool.drv

    Hi all I use the PrintTextFile function to display messages and here to warn users if for any reason any printer does not print.  I have a code which are looking for printer error, but I have to use windows SDK. I noticed that the basis of CVI does n

  • Should IRQ conflicts, I worry?

    original title: conflicts/sharing Should I be worried? Updateing just finished my new wife Dell INSPIRON zino HD Windows 7 Under system conflicts/sharing of Information, material resources... I got the following and may not know if items are conflict

  • How can I register the office settings and programs that I added?

    Whenever I have shut down the computer, back to original settings and doesn't give me a temporary profile. Many icons have disappeared and programs lack? Get frustrated having to re - install programs.  :( Thanks go out of any aid granted.

  • EBS R12.2.4 apps error level cloning

    Hi allEBS 12.2.4OEL 6.5I cloned the orauat db level successfully.And then I start cloning on the layer of appluat apps, but the clone process cannot connect to the databaseInventory global loc = /etc/oraInst.locJournal: /home/oraInventory/logs/instal