summaryrefslogtreecommitdiff
path: root/FS/bin/freeside-count-active-customers
blob: 759085a736d5f8b741a69927ca467a1e608717ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh

domain=$1

echo "\t
select count(*) from cust_main where 
          0 < ( SELECT COUNT(*) FROM cust_pkg
                       WHERE cust_pkg.custnum = cust_main.custnum
                         AND ( cust_pkg.cancel IS NULL
                               OR cust_pkg.cancel = 0
                             )
                   )
            OR 0 = ( SELECT COUNT(*) FROM cust_pkg
                       WHERE cust_pkg.custnum = cust_main.custnum
                   );
" | psql -U freeside -q $domain | head -1