Note that there are some explanatory texts on larger screens.

plurals
  1. POGrouped results according to one field
    primarykey
    data
    text
    <p>I have a table with 2 significant columns, one with a date and time, and another one with an amount of seconds (so, an integer).</p> <p>I wish to get how many seconds I have for each day of the week, and for each hour of the day.</p> <p>I managed to have this information with 24 rows for each day of the week, with the dow in one column, the hour in another one, and the amount of seconds in the last one. What I would love to have is it in just 7 rows, with one column being the dow and the other one an array or something with the 24 amounts of seconds.</p> <p>Any idea on how to get rid of it?</p> <p>The query I ended with is:</p> <pre><code>SELECT dow, hour, sum(duration/60) as minutes FROM( SELECT duration, extract( 'dow' from datetime ) as dow, extract( 'hour' from datetime ) as hour FROM "statistics" WHERE datetime between '2013-10-01' and '2013-11-01' and duration &gt;= 300 ) as foo GROUP BY dow, hour ORDER BY dow, hour </code></pre> <p>And this gives me a result like:</p> <pre><code> dow | hour | minuts -----+------+-------- 0 | 0 | 742 0 | 1 | 572 0 | 2 | 634 0 | 3 | 208 0 | 4 | 333 0 | 5 | 302 0 | 6 | 183 0 | 7 | 108 0 | 8 | 135 0 | 9 | 201 0 | 10 | 369 0 | 11 | 429 0 | 12 | 340 0 | 13 | 439 0 | 14 | 572 0 | 15 | 420 0 | 16 | 636 0 | 17 | 958 0 | 18 | 878 0 | 19 | 1176 0 | 20 | 995 0 | 21 | 740 0 | 22 | 783 0 | 23 | 857 1 | 0 | 474 1 | 1 | 576 1 | 2 | 431 1 | 3 | 157 1 | 4 | 140 1 | 5 | 55 1 | 6 | 17 1 | 8 | 118 1 | 9 | 356 1 | 10 | 994 1 | 11 | 930 1 | 12 | 1177 1 | 13 | 1228 1 | 14 | 896 1 | 15 | 1072 1 | 16 | 1254 1 | 17 | 1764 1 | 18 | 1303 1 | 19 | 1176 1 | 20 | 1314 1 | 21 | 1003 1 | 22 | 1161 1 | 23 | 811 ... </code></pre>
    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.
    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