---
title: "Analyzing cohorts in Interactive Queries"
date: "2024-02-14T06:18:38+00:00"
summary: "Unlock powerful cohort analysis in Customer Data Platform with Interactive Queries. Learn how to join audiencehistory and customersummary tables for deeper customer insights and revenue tracking."
image:
type: "page"
url: "/customer-data-platform/analyzing-cohorts-interactive-queries"
id: "c0ddf0ae-9b46-43ff-a32d-2bff5d92b6cc"
---

[Interactive Queries](/customer-data-platform/add-ons/interactive-queries) (IQ) and Snowflake Data Sharing provide full SQL access to cleansed, processed, and enriched data in Customer Data Platform (CDP). This includes customer summaries, transaction details at the line-level, atomic events, and much more. All data is automatically refreshed daily with zero setup and maintenance on your end.

With a Cohort Analysis subscription, you get access to all data associated with cohorts in IQ and Snowflake data sharing through the [audiencehistory](/customer-data-platform/add-ons/interactive-queries/list-of-attributes/audience-history) table. This table saves all marked cohorts, within the data retention window, with a timestamp. If you have an active IQ subscription, you can use free-form SQL to analyze cohorts with greater flexibility.

For more information on how the **audiencehistory** table functions, see [FAQs and troubleshooting](/customer-data-platform/troubleshooting).

The following is a sample query to join **audiencehistory** table with the **customersummary** table:

    SELECT cohort.audiencename  AS "campaign_name",
          customersummary.totalrevenuegroup  AS "revenue_lifetime",
          Count(DISTINCT customersummary.mastercustomerid) AS
          "all_individuals_count"
    FROM   customersummary
          LEFT JOIN mastercustomer
                  ON customersummary.mastercustomerid =
                    mastercustomer.mastercustomerid
          LEFT JOIN audiencehistory AS cohort
                  ON mastercustomer.customerid = cohort.mastercustomerid
    GROUP  BY 1, 2
    ORDER  BY 3 DESC
    LIMIT  500