På fredag 29. januar 2016 kl. 17:59:52, skrev David G. Johnston <david.g.johnston@gmail.com>:On Fri, Jan 29, 2016 at 9:45 AM, Andreas Joseph Krogh <andreas@visena.com> wrote:På fredag 29. januar 2016 kl. 02:43:37, skrev Andreas Joseph Krogh <andreas@visena.com>:På fredag 29. januar 2016 kl. 02:11:52, skrev Andreas Joseph Krogh <andreas@visena.com>:På fredag 29. januar 2016 kl. 02:02:46, skrev Michael Moore <michaeljmoore@gmail.com>:It is unclear to me how you got from your input data to your expected output. If you are "trying to count() overlapping entries" then it would seem to me that you would only have only one value for the count. Either a range overlaps or it does not. Oh, sorry, the count was in wrong order. Let me explain,insert into event(name, start_time, end_time) values('a', '2015-12-20', NULL) , ('a', '2015-12-20', '2015-12-31') , ('a', '2015-12-25', '2016-01-01') , ('b', '2015-11-20', '2015-11-24') , ('c', '2016-02-01', '2016-02-03') , ('c', '2016-02-01', '2016-02-04') , ('c', '2016-02-01', NULL) ; All 'a', 'b' and 'c' have points in common, with count a=3, b=1, c=3. Note that the 'name'-column here is just to explain what I'm after and that I have no such column. Any clever hints anyone? Maybe this will help...? https://wiki.postgresql.org/wiki/Range_aggregation David J. Yea, I've seen it, but don't like it. I was (am) hoping some clever PG-guy would step up and craft som clever GROUP BY stuff like "GROUP BY magic_gist_equals(tsrange with &&)" -- Andreas Joseph KroghCTO / Partner - Visena ASMobile: +47 909 56 963andreas@visena.comwww.visena.com
On Fri, Jan 29, 2016 at 9:45 AM, Andreas Joseph Krogh <andreas@visena.com> wrote:På fredag 29. januar 2016 kl. 02:43:37, skrev Andreas Joseph Krogh <andreas@visena.com>:På fredag 29. januar 2016 kl. 02:11:52, skrev Andreas Joseph Krogh <andreas@visena.com>:På fredag 29. januar 2016 kl. 02:02:46, skrev Michael Moore <michaeljmoore@gmail.com>:It is unclear to me how you got from your input data to your expected output. If you are "trying to count() overlapping entries" then it would seem to me that you would only have only one value for the count. Either a range overlaps or it does not. Oh, sorry, the count was in wrong order. Let me explain,insert into event(name, start_time, end_time) values('a', '2015-12-20', NULL) , ('a', '2015-12-20', '2015-12-31') , ('a', '2015-12-25', '2016-01-01') , ('b', '2015-11-20', '2015-11-24') , ('c', '2016-02-01', '2016-02-03') , ('c', '2016-02-01', '2016-02-04') , ('c', '2016-02-01', NULL) ; All 'a', 'b' and 'c' have points in common, with count a=3, b=1, c=3. Note that the 'name'-column here is just to explain what I'm after and that I have no such column. Any clever hints anyone? Maybe this will help...? https://wiki.postgresql.org/wiki/Range_aggregation David J.
På fredag 29. januar 2016 kl. 02:43:37, skrev Andreas Joseph Krogh <andreas@visena.com>:På fredag 29. januar 2016 kl. 02:11:52, skrev Andreas Joseph Krogh <andreas@visena.com>:På fredag 29. januar 2016 kl. 02:02:46, skrev Michael Moore <michaeljmoore@gmail.com>:It is unclear to me how you got from your input data to your expected output. If you are "trying to count() overlapping entries" then it would seem to me that you would only have only one value for the count. Either a range overlaps or it does not. Oh, sorry, the count was in wrong order. Let me explain,insert into event(name, start_time, end_time) values('a', '2015-12-20', NULL) , ('a', '2015-12-20', '2015-12-31') , ('a', '2015-12-25', '2016-01-01') , ('b', '2015-11-20', '2015-11-24') , ('c', '2016-02-01', '2016-02-03') , ('c', '2016-02-01', '2016-02-04') , ('c', '2016-02-01', NULL) ; All 'a', 'b' and 'c' have points in common, with count a=3, b=1, c=3. Note that the 'name'-column here is just to explain what I'm after and that I have no such column. Any clever hints anyone?
På fredag 29. januar 2016 kl. 02:11:52, skrev Andreas Joseph Krogh <andreas@visena.com>:På fredag 29. januar 2016 kl. 02:02:46, skrev Michael Moore <michaeljmoore@gmail.com>:It is unclear to me how you got from your input data to your expected output. If you are "trying to count() overlapping entries" then it would seem to me that you would only have only one value for the count. Either a range overlaps or it does not. Oh, sorry, the count was in wrong order. Let me explain,insert into event(name, start_time, end_time) values('a', '2015-12-20', NULL) , ('a', '2015-12-20', '2015-12-31') , ('a', '2015-12-25', '2016-01-01') , ('b', '2015-11-20', '2015-11-24') , ('c', '2016-02-01', '2016-02-03') , ('c', '2016-02-01', '2016-02-04') , ('c', '2016-02-01', NULL) ; All 'a', 'b' and 'c' have points in common, with count a=3, b=1, c=3. Note that the 'name'-column here is just to explain what I'm after and that I have no such column.
På fredag 29. januar 2016 kl. 02:02:46, skrev Michael Moore <michaeljmoore@gmail.com>:It is unclear to me how you got from your input data to your expected output. If you are "trying to count() overlapping entries" then it would seem to me that you would only have only one value for the count. Either a range overlaps or it does not. Oh, sorry, the count was in wrong order. Let me explain,insert into event(name, start_time, end_time) values('a', '2015-12-20', NULL) , ('a', '2015-12-20', '2015-12-31') , ('a', '2015-12-25', '2016-01-01') , ('b', '2015-11-20', '2015-11-24') , ('c', '2016-02-01', '2016-02-03') , ('c', '2016-02-01', '2016-02-04') , ('c', '2016-02-01', NULL) ; All 'a', 'b' and 'c' have points in common, with count a=3, b=1, c=3.
It is unclear to me how you got from your input data to your expected output. If you are "trying to count() overlapping entries" then it would seem to me that you would only have only one value for the count. Either a range overlaps or it does not.
insert into event(name, start_time, end_time) values('a', '2015-12-20', NULL) , ('a', '2015-12-20', '2015-12-31') , ('a', '2015-12-25', '2016-01-01') , ('b', '2015-11-20', '2015-11-24') , ('c', '2016-02-01', '2016-02-03') , ('c', '2016-02-01', '2016-02-04') , ('c', '2016-02-01', NULL) ;
pgsql-sql by date:
Соглашаюсь с условиями обработки персональных данных