Les abonnements B2C dupliqués sans l'original
Permet d'identifier les abonnements dupliqués à supprimer
1
2
3
4
5
6
7
8
9
10
11
12
13 | WITH duplicated_ols AS (
SELECT subscription.*, FIRST(subscription.id, subscription.created_at) AS subscription_id_to_keep
FROM organization_license_subscription AS subscription
WHERE subscription.subscription_cancel_reason IS NULL
AND subscription.deleted_at IS NULL
GROUP BY subscription.organization_license_id, subscription.payment_provider_code
HAVING COUNT(*) > 1
)
SELECT organization_license_subscription.*
FROM organization_license_subscription
JOIN duplicated_ols
ON duplicated_ols.id = organization_license_subscription.id
AND duplicated_ols.subscription_id_to_keep != organization_license_subscription.id;
|
Keywords
select all organization_license_subscription B2C duplicated