Note that there are some explanatory texts on larger screens.

plurals
  1. POGrouping and summarize columns
    primarykey
    data
    text
    <p>Given the tables below, what is the best approach to (in both server-flavors):</p> <p>Group all rows within a minute/hour/day and get the maximum column 'CounterC' ?</p> <p>Example: Between 'now' and 'now' - 1 day, get Max(CounterC) for each hour. Example2: Between 'now' and 'now' - 30 days, get Max(CounterC) for each day.</p> <p>Obviously the rows have to be grouped, but how?</p> <p>MS SQL</p> <pre><code>CREATE TABLE [dbo].[DE0000000D102D1D]( [index] [bigint] IDENTITY(1,1) NOT NULL, [TimeStamp] [datetime] NOT NULL, [CounterA] [bigint] NOT NULL, [CounterB] [bigint] NOT NULL, [CounterC] [bigint] NOT NULL, [CounterD] [bigint] NOT NULL, ) </code></pre> <p>MySQL</p> <pre><code>CREATE TABLE `de0000000d102d1d` ( `index` bigint(20) NOT NULL AUTO_INCREMENT, `TimeStamp` datetime NOT NULL, `CounterA` bigint(20) NOT NULL, `CounterB` bigint(20) NOT NULL, `CounterC` bigint(20) NOT NULL, `CounterD` bigint(20) NOT NULL, PRIMARY KEY (`index`) ) </code></pre> <p>Some example data:</p> <pre><code>index TimeStamp CounterA CounterB CounterC CounterD ----- ----------------------- -------- -------- --------- -------- 1 2011-03-07 14:25:32.000 0 1 347406352 916 2 2011-03-07 14:26:32.000 0 1 347407169 916 3 2011-03-07 14:27:32.000 0 1 347407978 916 4 2011-03-07 14:28:31.000 0 1 347408617 916 5 2011-03-07 14:29:31.000 0 1 347409087 916 6 2011-03-07 14:30:30.000 0 1 347409557 916 7 2011-03-07 14:31:09.000 0 1 347409845 916 </code></pre> <p>Thanks in advance!</p> <p>Edit: It is actually Max(CounterC) I want for each interval, not the sum.</p>
    singulars
    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.
 

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