pgsql/update_tables_0.5.x-0.6-dovecot-1.2.x.pgsql
branchv0.6.x
changeset 388 dd95ed5bc9d2
parent 387 05dc4e1f8dff
child 391 8217ddd5220d
equal deleted inserted replaced
387:05dc4e1f8dff 388:dd95ed5bc9d2
   133            AS maildir
   133            AS maildir
   134       FROM users
   134       FROM users
   135            LEFT JOIN domain_data USING (gid)
   135            LEFT JOIN domain_data USING (gid)
   136            LEFT JOIN domain_name USING (gid)
   136            LEFT JOIN domain_name USING (gid)
   137            LEFT JOIN maillocation USING (mid);
   137            LEFT JOIN maillocation USING (mid);
       
   138 
       
   139 CREATE OR REPLACE VIEW vmm_domain_info AS
       
   140     SELECT gid, domainname, transport, domaindir,
       
   141            count(uid) AS accounts,
       
   142            (SELECT count(DISTINCT address)
       
   143               FROM alias
       
   144              WHERE alias.gid = domain_data.gid) AS aliases,
       
   145            (SELECT count(gid)
       
   146               FROM relocated
       
   147              WHERE relocated.gid = domain_data.gid) AS relocated,
       
   148            (SELECT count(gid)
       
   149               FROM domain_name
       
   150              WHERE domain_name.gid = domain_data.gid
       
   151                AND NOT domain_name.is_primary) AS aliasdomains,
       
   152            bytes, messages
       
   153       FROM domain_data
       
   154            LEFT JOIN domain_name USING (gid)
       
   155            LEFT JOIN quotalimit USING (qid)
       
   156            LEFT JOIN transport USING (tid)
       
   157            LEFT JOIN users USING (gid)
       
   158      WHERE domain_name.is_primary
       
   159   GROUP BY gid, domainname, transport, domaindir, bytes, messages;