Skip to content

Les licences actives d'un user

1
2
3
4
5
6
7
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

1
2
3
4
5
6
7
8
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

1
2
3
4
5
6
7
8
9
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

1
2
3
4
5
6
7
8
9
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