Re:Seldomly Used SQL: The Bool Aggregate Functions
by mjevans on Thursday May 05, 2016 @12:46PM
(#11637681)
It still has to get the data from every row, unless you happened to make an index that correlates the two columns in just the right order.
This is where a more effective question would be more useful.
A question like 'in the last quarter, how many sales did we have for each category and shipping type?' You can then take the results and calculate more useful values like the percentage of express shipments, etc.
Re:Seldomly Used SQL: The Bool Aggregate Functions
by mcherm on Friday May 06, 2016 @07:56AM
(#11643288)
I don't think that author's examples are particularly useful because, just as you point out, on any decent-sized dataset at least a COUPLE of customers will have chosen to behave oddly.
But they seem quite handy for searching for bad data in the database, rather than analyzing customer behavior.
SELECT cateogry FROM orders WHERE express_delivery=TRUE GROUP BY category
Also are these aggregate functions as efficient?