Re: [sqlite] Finding the largest TOTAL() of numerous GROUP totals

2017-01-25 Thread R Smith
On 2017/01/25 6:15 PM, Simon Slavin wrote: On 25 Jan 2017, at 4:14pm, R Smith wrote: Maybe I'm misunderstanding some fundamental principle, but I don't see how TOTAL(count) is equivalent to TOTAL(*)? COUNT(some_field_name) and COUNT(*) might be equivalent, but I'm

Re: [sqlite] Finding the largest TOTAL() of numerous GROUP totals

2017-01-25 Thread Simon Slavin
On 25 Jan 2017, at 4:14pm, R Smith wrote: > Maybe I'm misunderstanding some fundamental principle, but I don't see how > TOTAL(count) is equivalent to TOTAL(*)? COUNT(some_field_name) and COUNT(*) > might be equivalent, but I'm wondering how total would know which column

Re: [sqlite] Finding the largest TOTAL() of numerous GROUP totals

2017-01-25 Thread R Smith
On 2017/01/25 1:36 PM, Simon Slavin wrote: On 25 Jan 2017, at 5:13am, Jeffrey Mattox wrote: (1) SELECT TOTAL(count) as grandTotalCount FROM History Please try replacing TOTAL(count) with TOTAL(*). Nothing to do with your question but it may lead to faster results with

Re: [sqlite] Finding the largest TOTAL() of numerous GROUP totals

2017-01-25 Thread Simon Slavin
On 25 Jan 2017, at 5:13am, Jeffrey Mattox wrote: > (1) SELECT TOTAL(count) as grandTotalCount FROM History Please try replacing TOTAL(count) with TOTAL(*). Nothing to do with your question but it may lead to faster results with less processing. Simon.

Re: [sqlite] Finding the largest TOTAL() of numerous GROUP totals

2017-01-24 Thread Clemens Ladisch
Jeffrey Mattox wrote: > Can (1) and (3) be combined to return grandTotalCount and > largestSubTotalCount? In the general case, you can combine them in two columns: SELECT (SELECT ...) AS grandTotalCount, (SELECT ...) AS largestSubTotalCount; or in two rows: SELECT ... UNION ALL SELECT

Re: [sqlite] Finding the largest TOTAL() of numerous GROUP totals

2017-01-24 Thread R Smith
On 2017/01/25 7:13 AM, Jeffrey Mattox wrote: I use this query to get a grand total of a number of counts: (1) SELECT TOTAL(count) as grandTotalCount FROM History Next, I step through the counts, grouped by column 'hour: (2a) SELECT TOTAL(count) as subTotalCount, hour FROM History

[sqlite] Finding the largest TOTAL() of numerous GROUP totals

2017-01-24 Thread Jeffrey Mattox
I use this query to get a grand total of a number of counts: (1) SELECT TOTAL(count) as grandTotalCount FROM History Next, I step through the counts, grouped by column 'hour: (2a) SELECT TOTAL(count) as subTotalCount, hour FROM History GROUP BY hour I use grandTotalCount in the loop to