Re: [sqlite] SQL help: by-range aggregation

2017-03-09 Thread R Smith
On 2017/03/09 10:11 AM, Dominique Devienne wrote: Nice! Thanks Ryan. --DD PS: If we ever meet, your reasonably-priced beverage of choice is on me :) You're welcome, and safe, since I'm teetotal - which means I totally only drink tea. :) (Been this way since that fatal PUI incident - that's

Re: [sqlite] SQL help: by-range aggregation

2017-03-09 Thread Dominique Devienne
On Wed, Mar 8, 2017 at 6:38 PM, R Smith wrote: > > On 2017/03/08 5:35 PM, Dominique Devienne wrote: > >> >> Now I only need a CTE to dynamically generate the ranges, >> > > Well, that seems like fun! > If I may... > Nice! Thanks Ryan. --DD PS: If we ever meet, your reasonably-priced beverage of

Re: [sqlite] SQL help: by-range aggregation

2017-03-09 Thread Dominique Devienne
On Wed, Mar 8, 2017 at 6:08 PM, Simon Slavin wrote: > > On 8 Mar 2017, at 3:35pm, Dominique Devienne wrote: > > > > Then the results where in alphabetical order of bucket names, > > so I had to re-join on ranges to order by ranges.low. > > You should be able to just add the ORDER BY clause to th

Re: [sqlite] SQL help: by-range aggregation

2017-03-08 Thread R Smith
On 2017/03/08 5:35 PM, Dominique Devienne wrote: Now I only need a CTE to dynamically generate the ranges, Well, that seems like fun! If I may... -- CTEs -- Units Table (B, KB, MB, etc.) WITH UT(id, uStr, byteDiv) AS ( SELECT 0, 'B', 1 UNION ALL SELECT UT.id+1, CASE

Re: [sqlite] SQL help: by-range aggregation

2017-03-08 Thread Simon Slavin
On 8 Mar 2017, at 3:35pm, Dominique Devienne wrote: > > Then the results where in alphabetical order of bucket names, > so I had to re-join on ranges to order by ranges.low. You should be able to just add the ORDER BY clause to the original JOIN: SELECT ranges.name, bytes_per_set.v FROM bytes

Re: [sqlite] SQL help: by-range aggregation

2017-03-08 Thread Dominique Devienne
On Wed, Mar 8, 2017 at 3:47 PM, Clemens Ladisch wrote: > Dominique Devienne wrote: > > On Wed, Mar 8, 2017 at 3:16 PM, Hick Gunter wrote: > >> Alternatively create a "range" table, insert your defined ranges and > >> join/subquery to the original query. > > > > That's the easy part [...] > > but

Re: [sqlite] SQL help: by-range aggregation

2017-03-08 Thread Simon Slavin
On 8 Mar 2017, at 2:33pm, Dominique Devienne wrote: > Same constraints of the "thousand separator" one, this will be a view in a > DB to be viewed by any SQLite client, so not allowed here. --DD In that case, I think Hick’s solution is good. Do it in two steps: construct a temporary table whi

Re: [sqlite] SQL help: by-range aggregation

2017-03-08 Thread Clemens Ladisch
Dominique Devienne wrote: > On Wed, Mar 8, 2017 at 3:16 PM, Hick Gunter wrote: >> Alternatively create a "range" table, insert your defined ranges and >> join/subquery to the original query. > > That's the easy part [...] > but the join/subquery you mention is still leaving me scratching my head..

Re: [sqlite] SQL help: by-range aggregation

2017-03-08 Thread Dominique Devienne
On Wed, Mar 8, 2017 at 3:16 PM, Hick Gunter wrote: > Alternatively create a "range" table, insert your defined ranges and > join/subquery to the original query. > > Create table range (label text, from integer, to integer); > That's the easy part (and a CTE can probably generate it dynamically,

Re: [sqlite] SQL help: by-range aggregation

2017-03-08 Thread Dominique Devienne
On Wed, Mar 8, 2017 at 2:53 PM, Simon Slavin wrote: > On 8 Mar 2017, at 1:46pm, Dominique Devienne wrote: > > I'd like to aggregate the sum of the size per-parent, from 1KB, to each > > range > > from low to 8*low (i.e. [low, 8*low)), but w/o having to write my hand > all > > possible > > combin

Re: [sqlite] SQL help: by-range aggregation

2017-03-08 Thread Hick Gunter
von Simon Slavin Gesendet: Mittwoch, 08. März 2017 14:53 An: SQLite mailing list Betreff: Re: [sqlite] SQL help: by-range aggregation On 8 Mar 2017, at 1:46pm, Dominique Devienne wrote: > I'd like to aggregate the sum of the size per-parent, from 1KB, to > each range from low to 8*

Re: [sqlite] SQL help: by-range aggregation

2017-03-08 Thread Simon Slavin
On 8 Mar 2017, at 1:46pm, Dominique Devienne wrote: > I'd like to aggregate the sum of the size per-parent, from 1KB, to each > range > from low to 8*low (i.e. [low, 8*low)), but w/o having to write my hand all > possible > combination, with extra points for formatting the range bounds in KB, MB

[sqlite] SQL help: by-range aggregation

2017-03-08 Thread Dominique Devienne
Given a table with a (parent, child) PK, which carries a size "data" column, I'd like to aggregate the sum of the size per-parent, from 1KB, to each range from low to 8*low (i.e. [low, 8*low)), but w/o having to write my hand all possible combination, with extra points for formatting the range boun