Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL Query Get Max Value At Occured Date
    primarykey
    data
    text
    <p>So we are doing some traffic reporting in our department. Therefore we got a table named traffic_report, which is build up like</p> <pre><code>╔════════════════╦═══════════╦═════════════════════╦═════════════╦═════════════╗ ║ hostname ║ interface ║ date_gmt ║ intraf_mpbs ║ outraf_mbps ║ ╠════════════════╬═══════════╬═════════════════════╬═════════════╬═════════════╣ ║ my-machine.com ║ NIC-5 ║ 2013-09-18 09:55:00 ║ 32 ║ 22 ║ ║ my-machine.com ║ NIC-5 ║ 2013-09-17 08:25:00 ║ 55 ║ 72 ║ ║ my-machine.com ║ NIC-5 ║ 2013-09-16 05:12:00 ║ 65 ║ 2 ║ ║ my-machine.com ║ NIC-5 ║ 2013-09-15 04:46:00 ║ 43 ║ 5 ║ ║ my-machine.com ║ NIC-5 ║ 2013-09-14 12:02:00 ║ 22 ║ 21 ║ ║ my-machine.com ║ NIC-5 ║ 2013-09-13 22:13:00 ║ 66 ║ 64 ║ ╚════════════════╩═══════════╩═════════════════════╩═════════════╩═════════════╝ </code></pre> <p>I'd like to fetch the maximum of the traffic in and traffic out at the occured date. My approach doing so is like this</p> <pre><code>SELECT hostname, interface, date_gmt, max(intraf_mbps) as max_in, max(outtraf_mbps) as max_out FROM traffic_report GROUP by hostname, interface </code></pre> <p>The approach produces a table like this</p> <pre><code>╔════════════════╦════════════╦═════════════════════╦════════╦═════════╗ ║ hostname ║ interface ║ date_gmt ║ max_in ║ max_out ║ ╠════════════════╬════════════╬═════════════════════╬════════╬═════════╣ ║ my-machine.com ║ NIC-5 ║ 2013-09-18 09:55:00 ║ 66 ║ 72 ║ ╚════════════════╩════════════╩═════════════════════╩════════╩═════════╝ </code></pre> <p>The problem is, the date_gmt displayed is just the date of the first record entered to the table.</p> <p>How do I instruct SQL to display me the date_gmt at which the max(intraf_mbps) occured?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload