pgsql/update_tables_0.5.x-0.6.pgsql
branchv0.6.x
changeset 388 dd95ed5bc9d2
parent 387 05dc4e1f8dff
child 391 8217ddd5220d
equal deleted inserted replaced
387:05dc4e1f8dff 388:dd95ed5bc9d2
   111            AS maildir
   111            AS maildir
   112       FROM users
   112       FROM users
   113            LEFT JOIN domain_data USING (gid)
   113            LEFT JOIN domain_data USING (gid)
   114            LEFT JOIN domain_name USING (gid)
   114            LEFT JOIN domain_name USING (gid)
   115            LEFT JOIN maillocation USING (mid);
   115            LEFT JOIN maillocation USING (mid);
       
   116 
       
   117 CREATE OR REPLACE VIEW vmm_domain_info AS
       
   118     SELECT gid, domainname, transport, domaindir,
       
   119            count(uid) AS accounts,
       
   120            (SELECT count(DISTINCT address)
       
   121               FROM alias
       
   122              WHERE alias.gid = domain_data.gid) AS aliases,
       
   123            (SELECT count(gid)
       
   124               FROM relocated
       
   125              WHERE relocated.gid = domain_data.gid) AS relocated,
       
   126            (SELECT count(gid)
       
   127               FROM domain_name
       
   128              WHERE domain_name.gid = domain_data.gid
       
   129                AND NOT domain_name.is_primary) AS aliasdomains,
       
   130            bytes, messages
       
   131       FROM domain_data
       
   132            LEFT JOIN domain_name USING (gid)
       
   133            LEFT JOIN quotalimit USING (qid)
       
   134            LEFT JOIN transport USING (tid)
       
   135            LEFT JOIN users USING (gid)
       
   136      WHERE domain_name.is_primary
       
   137   GROUP BY gid, domainname, transport, domaindir, bytes, messages;