---
title: Data Distiller
slug: nrg-rtcdp-hands-on-lab/data-distiller
docTags: 
createdAt: 2026-05-07T05:20:04.766Z
---

In this module you'll learn how to use Adobe's Query Service and Data Distiller to query the data that has been ingested into Adobe Experience Platform. &#x20;

Use the solution switcher to return to AEP. &#x20;

## Run a simple query&#x20;

Browse to **Queries&#x20;**&#x75;nder **Data Management.  &#x20;**&#x43;lick to **Create Query. &#x20;**

![](https://api.archbee.com/api/optimize/1Jp0iolWv35Z_mkI7oUiT/nDORil3oHZUCfTK8FBwZ6_image.png)

For this exercise we'll use a query to count how many profiles we have per loyalty tier.  Use the following SQL:&#x20;

```sql
select
  count(*),
  _adobeamericaspot5.lumacustomerdetails.churnpredictionscore
from
  luma_customer_details
group by
  2;
```

Click the play button to run the query >.

![](https://api.archbee.com/api/optimize/1Jp0iolWv35Z_mkI7oUiT/PXqlH7_SOK6jhvd6R3Zlb-20260507-052639.png)

## Journey Analysis Query

Adobe has added a set of **Adobe Defined Functions&#x20;**&#x74;o the standard SQL Syntax that allow you to better understand customer experience data by querying the sequence of events.    &#x20;

In this query we will answer, **what do people do on the site before reaching the "Home" page, and what do they browse next?&#x20;**

With this query you will discover the first two Adobe Defined Functions **SESS\_TIMEOUT** and **NEXT**.

The **SESS\_TIMEOUT()** reproduces the visit groupings found with Customer Journey Analytics. It performs a similar time-based grouping, but customizable parameters.

**NEXT()** and **PREVIOUS()** help you to understand how customers navigate your site.

```sql
SELECT
  webPage, 
  webPage_2, 
  webPage_3, 
  webPage_4, 
  count(*) journeys
FROM(
  SELECT webPage, 
    NEXT(webPage, 1, true) OVER(PARTITION BY ecid, session.num ORDER BY timestamp ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING).value AS webPage_2,
    NEXT(webPage, 2, true) OVER(PARTITION BY ecid, session.num ORDER BY timestamp ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING).value AS webPage_3,
    NEXT(webPage, 3, true) OVER(PARTITION BY ecid, session.num ORDER BY timestamp ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING).value AS webPage_4,
    session.depth AS SessionPageDepth 
  FROM (
     SELECT a._adobeamericaspot5.identification.core.ecid as ecid, 
        a.timestamp, web.webPageDetails.name as webPage, 
        SESS_TIMEOUT(timestamp, 60 * 60 * 168) OVER (PARTITION BY a._adobeamericaspot5.identification.core.ecid ORDER BY timestamp ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS session
     FROM demo_system_event_dataset_for_website_global_v1_1 a 
     WHERE a._adobeamericaspot5.identification.core.ecid IN (
         SELECT  b._adobeamericaspot5.identification.core.ecid 
         FROM demo_system_event_dataset_for_website_global_v1_1 b 
         WHERE web.webPageDetails.name = 'home' 
         and b._adobeamericaspot5.identification.core.ecid IS NOT NULL
       ) 
     )
   )
WHERE SessionPageDepth=1 and webpage_3 = 'home'
GROUP BY webPage, webPage_2, webPage_3, webPage_4 
ORDER BY journeys DESC
LIMIT 10;
```

Create a new query and run this sql to see the results:&#x20;

![](https://api.archbee.com/api/optimize/1Jp0iolWv35Z_mkI7oUiT/D7XGDrNIbx1CQVBx3rBI3-20260507-052826.png)

If I want to export the results of this query I must first add them to a dataset.   I can use the Create Table As Select (CTAS) feature to do that.  Click **Run as CTAS,&#x20;**&#x67;ive your dataset a name and click **Run.**

![](https://api.archbee.com/api/optimize/1Jp0iolWv35Z_mkI7oUiT/FHuboz2oEDJi-c2F2YS9n-20260507-052945.png)

This will create a job in the background to create a new dataset with the results from your query.  You can then export that dataset using the destinations service.   We will cover this piece tomorrow. &#x20;

## Create a scheduled query

What if you need to configure some transformations to happen on a recurring basis?   You can do this by first turning your adhoc query into a query template.  Add a **name** to the query from the previous exercise.  Then click **Save and Close.**

![](https://api.archbee.com/api/optimize/1Jp0iolWv35Z_mkI7oUiT/ihMrclXYZTL9umAm698yN_image.png)

Your query now appears in the template list.  If you select the query you can choose to **Add Schedule.**

![](https://api.archbee.com/api/optimize/1Jp0iolWv35Z_mkI7oUiT/TklhhgDckxydTjqzZuY4v_image.png)

From here you can set up the schedule to execute the query as frequently as every hour and to append the data from each execution into a dataset.  &#x20;

![](https://api.archbee.com/api/optimize/1Jp0iolWv35Z_mkI7oUiT/8WD8AN588aiTDdH-UFUH7_image.png)

In this way we can quickly set up transformation jobs to execute on a recurring basis which can be particularly useful prior to ingesting data into Customer Journey Analytics. &#x20;

The snapshot clause is another query service feature that can be useful when setting up these automated processes.  You can read more about it here: [https://experienceleague.adobe.com/en/docs/experience-platform/query/sql/syntax#snapshot-clause](https://experienceleague.adobe.com/en/docs/experience-platform/query/sql/syntax#snapshot-clause)

:::hint{type="success"}
Congratulations, you've completed the module on Data Distiller
:::

