Re: [h2] Only show changes in GROUP BY

2014-01-14 Thread Thomas Mueller
Hi, OK I see, what about: DROP TABLE IF EXISTS test; CREATE TABLE test(year INT, month INT); INSERT INTO test (year, month) VALUES (2000, 1), (2000, 2), (2000, 3), (2000, 4), (2000, 5), (2000, 6), (2001, 1), (2002, 2), (2002, 3), ; SELECT rownum(), year, month, @prev := case when rownum()=1

Re: [h2] Only show changes in GROUP BY

2014-01-13 Thread Thomas Mueller
Hi, H2 supports running totals in the MySQL style. Maybe the following could be used as a start: drop table test; create table test(year int, month int); insert into test values(2000, 1), (2000, 2), (2000, 3), (2001, 1); select @y := case when rownum()=1 then year when @y = year then null else

Re: [h2] Only show changes in GROUP BY

2014-01-11 Thread Cecil Westerhof
2014/1/10 Noel Grandin noelgran...@gmail.com On 2014-01-09 23:43, Cecil Westerhof wrote: This works fine, but I would prefer to only have Date shown when it is different as the previous Date. Is this possible? Depends on what you mean by previous date? You didn't show the table

Re: [h2] Only show changes in GROUP BY

2014-01-11 Thread Atul Chowdhury
You're probably after something like the BREAK directive found in SQL*Plus. See: http://docs.oracle.com/cd/A84870_01/doc/sqlplus.816/a75664/ch42.htm SQL BREAK ON DEPTNO SQL SELECT DEPTNO, ENAME, SAL 2 FROM EMP 3 WHERE SAL 2500 4 ORDER BY DEPTNO; SQL*Plus displays the following output:

Re: [h2] Only show changes in GROUP BY

2014-01-11 Thread Cecil Westerhof
2014/1/11 Atul Chowdhury atulsmail...@gmail.com You're probably after something like the BREAK directive found in SQL*Plus. See: http://docs.oracle.com/cd/A84870_01/doc/sqlplus.816/a75664/ch42.htm SQL BREAK ON DEPTNO SQL SELECT DEPTNO, ENAME, SAL 2 FROM EMP 3 WHERE SAL 2500 4

Re: [h2] Only show changes in GROUP BY

2014-01-11 Thread Ryan How
If the timestamps are unique you could try including a subquery which gets the next lowest date eg. (not sure if this is valid SQL syntax, I'm not meant to be on the PC :) Select data, datetimefield, (select top 1 datetimefield from table1 where datetimefield A.datetimefield order by

Re: [h2] Only show changes in GROUP BY

2014-01-10 Thread Ryan How
Wouldn't you usually do that in your reporting software? Or on any layer on top of the database? In MS Access I've done it using a custom function which stores the last value and then only outputs the next value if it is different. Not sure how to do that in H2 ? Probably via a custom

[h2] Only show changes in GROUP BY

2014-01-09 Thread Cecil Westerhof
I have the following SQL: SELECT date AS Date ,SUBSTRING(time, 1, 2) AS Hour ,MIN(idleTime) AS `Min Idle` ,MAX(idleTime) AS `Max Idle` ,COUNT(*) AS SUM FROM vmstatDefault GROUP BY Date ,Hour ORDER BY Date ,