On Mon Sep 11, 2017 at 11:15:22AM +0200, no...@null.net wrote:
>     SELECT
>         acc_no,
>         acc_name,
>         SUM(i_90.invoice_bal) AS 90_days,
>         SUM(i_current.invoice_bal) AS current
>     FROM
>        debtors_table
>     LEFT JOIN
>         invoices i_90
>     ON
>         i_90.debtor_id = debtors_table.id AND
>         i_90.invoice_date > date_5 AND
>         i_90.invoice_date <= date_4
>     LEFT JOIN
>         invoices i_current
>     ON
>         i_current.debtor_id = debtors_table.id AND
>         i_current.invoice_date > date_2 AND
>         i_current.invoice_date <= date_1

I should also mention for completeness the need for:

    GROUP BY
        acc_no,
        acc_name

>     ORDER BY
>         ...

-- 
Mark Lawrence
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to