[freeside-users] Postgres query help?

Gerald V. Livingston II gerald.freeside at sysmatrix.net
Sun Jul 22 10:41:22 PDT 2007

On Sun, 22 Jul 2007 11:38:05 -0500 (Central Standard Time) "Gerald V.
Livingston II" <gerald.freeside at sysmatrix.net> wrote:

> freeside 1.5.8 running on a Debian Linux box. PostgreSQL 7.4.7

> I can't get my head wrapped around this one. I need to spit out a list of
> customers who are set up for POSTAL billing. There was a problem during a
> change of ownership at the business and I need to go through and reprint
> their invoices for the last 3 months after crediting off any late fees that
> were generated.
> I got as far as 
> SELECT cust_main.custnum WHERE cust_main_invoice.dest='POST'
> But, that returns ALL of the old customers who no longer have active
> packages and returns a row for each postal invoice that has ever been
> generated for each customer. I just want a single customer number for each
> active customer that is currently set to postal billing. Which table
> indicates this for the WHERE portion of the query?


SELECT cust_main_invoice.custnum WHERE cust_main_invoice.dest='POST'

returns only a single row for each custnum that has had a POST bill
generated. The cancelled accounts are still there but the size of the
returned list is much more manageable as we only have about 20 POST
customers (including he cancelled ones).


More information about the freeside-users mailing list