Skip to content

Instantly share code, notes, and snippets.

@daniloalsilva
Last active February 27, 2018 20:10
Show Gist options
  • Select an option

  • Save daniloalsilva/e3e205a856ca83e678ba to your computer and use it in GitHub Desktop.

Select an option

Save daniloalsilva/e3e205a856ca83e678ba to your computer and use it in GitHub Desktop.
Select all service plans and its general info:
-- Select all service plans with Presence Builder enable:
select t.name, td.element, td.value
from templates t, TmplData td
where td.tmpl_id = t.id
and td.element = 'max_site_builder'
and td.value <> 0;
-- Select all domains with Presence Builder enable:
select c.login, d.name as domain, t.name as subscription, l.value as limit_value
from subscriptions su, subscriptionproperties sp, domains d, planssubscriptions p, templates t, clients c, limits l
where sp.subscription_id = su.id
and d.id = su.object_id
and p.subscription_id = sp.subscription_id
and p.plan_id = t.id
and c.id = d.vendor_id
and sp.name = 'limitsId'
and sp.value = l.id
and l.limit_name='max_site_builder'
and l.value <> 0;
-- Select all service plans and its general info:
select p.id AS id, MAX(p.name) AS planName, MAX(p.type) AS planType, MAX(p.external_id) AS externalId, MAX(c.id) AS ownerId, MAX(c.type) AS ownerType, MAX(c.pname) AS ownerContactName, MAX(c.cname) AS ownerCompanyName, sum(ps.quantity) AS subscriptions, MAX(pt.value) AS traffic, MAX(pd.value) AS diskSpace
from Templates AS p
left join clients AS c ON c.id = p.owner_id
left join PlansSubscriptions AS ps ON p.id = ps.plan_id
left join TmplData AS pt ON pt.tmpl_id = p.id AND pt.element='max_traffic'
left join TmplData AS pd ON pd.tmpl_id = p.id AND pd.element='disk_space' WHERE (p.name <> 'Admin Simple') GROUP BY p.id ORDER BY planName ASC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment