The `subscription_coupons` table lists the coupons applied to a specific subscription.
UPSERT KEY
subscription_id + record_id

Each row is uniquely identified by this combination. Use these columns together as the upsert key when applying incremental datasets to your warehouse.

Columns

No match found

subscription_id string, not null
Foreign Key subscriptions.id
The unique identifier of the `subscription` this record is associated with.

coupon_id string, not null
Foreign Key coupons.id
A unique identifier for the coupon.

applied_count not null, default=0
The number of times a coupon has been applied to a subscription.

apply_till timestamp, null
The date until which the coupon remains valid. This applies only to `limited_period` coupons.

change_type string
The column indicates the type of change [create, update, delete, read] and can be used to load data into the warehouse accordingly.

coupon_code string, null
The code used to redeem the coupon. This is available only when a coupon with an associated `coupon_code` is used.

record_exported_at timestamp
The column represents the timestamp when the data was exported to the configured destination.

record_extracted_at timestamp
The column represents the timestamp when the updated data became available in Chargebee's data lakehouse.

record_id integer
The column represents the unique integer identifier for each child record within a parent subset.

Sample Queries

Subscriptions with Coupons Applied
Finds the list of subscriptions that have coupons applied, along with coupon details.
copy
Click to Copy
      SELECT
  s.id as subs_id,
  s.status as subs_status,
  c.name AS coupon_name,
  c.redemptions,
  sc.coupon_code
FROM
  subscriptions s
  JOIN subscription_coupons sc ON s.id = sc.subscription_id
  JOIN coupons c ON sc.coupon_id = c.id;