equivalent to DISTINCT ON (with SUM()) for in-memory SQLite
pete at lcsql.com
Fri Jan 8 02:41:24 CET 2016
I think this will work
SELECT sum(due) from mytable WHERE <whatever> ORDER BY cname || caddr GROUP
BY cname || caddr
GROUP may have to come before ORDER, don't remember.
On Thu, Jan 7, 2016 at 4:32 PM Dr. Hawkins <dochawk at gmail.com> wrote:
> I need to sum amounts and return keys where other fields are the same on an
> in-memory database.
> I have my own unique key uniqDna, fields cname and cadr, and numeric field
> I want to SUM(due) for each unique cname||cadr, and get get the
> corresponding keys.
> DISTINCT ON would due this, but it's not supported by SQLite.
> At the moment, I'm not seeing any approach other than returning them all,
> and using cname||cadr as a matrix key, and summing myself.
> Dr. Richard E. Hawkins, Esq.
> (702) 508-8462
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
More information about the use-livecode