Les licences actives d'un user
| SELECT * AS license_count FROM organization_license
WHERE organization_license.user_id = 1613153
AND organization_license.starts_at <= NOW()
AND (
organization_license.ends_at >= NOW() OR
organization_license.ends_at IS NULL
);
|
Filtre B2C
| SELECT * AS license_count FROM organization_license
WHERE organization_license.organization_id = 399
AND organization_license.user_id = 1613153
AND organization_license.starts_at <= NOW()
AND (
organization_license.ends_at >= NOW() OR
organization_license.ends_at IS NULL
);
|
Par produit
| SELECT * AS license_count FROM organization_license
LEFT JOIN plan ON plan.id = organization_license.plan_id
WHERE plan.product_code = 'EXAM'
AND organization_license.user_id = 1613153
AND organization_license.starts_at <= NOW()
AND (
organization_license.ends_at >= NOW() OR
organization_license.ends_at IS NULL
);
|
Par type de plan
| SELECT * AS license_count FROM organization_license
LEFT JOIN plan ON plan.id = organization_license.plan_id
WHERE plan.meta::$type = "BASIC" # PREMIUM | PREMIUM_PLUS...
AND organization_license.user_id = 1613153
AND organization_license.starts_at <= NOW()
AND (
organization_license.ends_at >= NOW() OR
organization_license.ends_at IS NULL
);
|
Keywords
select active licence user B2C plan product_code