---
title: Query Editor UI
slug: data-distiller-august-2024/query-editor-ui
description: Getting Started with Data Distiller
docTags: 
createdAt: 2023-11-15T14:46:41.704Z
---

```yaml
description: Getting Started with Data Distiller
```

### Query Editor [#query-editor](#)&#x20;

Data Distiller provides a user interface that can be used to write and execute queries, view previously executed queries, and access queries saved by users within your organization. The Query Editor enables you to write and execute queries without using an external client.&#x20;

To start this exercise click on Queries in the left side navigation then click on Create Query.

![](https://adbecdn.azureedge.net/labs/archbee/DataDistillerBase/ScreenShot2023-07-17at8.10.26AM1.png)

Let's test and make sure that we are connected to run a query.&#x20;

Type in the following query:

```sql
SELECT COUNT(_adobeamericaspot5.personDetails.loyaltyDetails.loyaltyLevel)
FROM crm_fsi;
```

Then run the query. You should get a count of 5000 in the results tab.

![](https://adbecdn.azureedge.net/labs/archbee/DataDistillerBase/ScreenShot2023-07-17at8.18.07AM.png)

Now that we have confirmed that we are all connected let's begin the exercise. You have been tasked with joining customer profile data with event data that are stored in 2 separate datasets in AEP and need to use Data Distiller to join this data into a single dataset.&#x20;

You will run a query to grab information from a CRM Profile by grabing the customers favorite city and state to travel to, if they have a reward card, and will filter the data by gold customers.

```sql
SELECT _adobeamericaspot5.memberInfo.branchCity as branchCity,
    _adobeamericaspot5.memberInfo.branchState as branchState,
    _adobeamericaspot5.memberInfo.hasRewardCard as hasRewardCard
FROM crm_fsi
WHERE _adobeamericaspot5.personDetails.loyaltyDetails.loyaltyLevel LIKE '%Gold%';
```

![](https://adbecdn.azureedge.net/labs/archbee/DataDistillerBase/ScreenShot2023-07-17at8.26.41AM.png)

Now that you have selected some fields from CRM Profile dataset, you are now going to run a join query to collect some data from a booking dataset. Both datasets have a shared identity with a Loyalty ID where you will be able to make the join with.&#x20;

From the Bookings Dataset you will be collecting if confirmed, date, number of nights, points, and nightly rate.&#x20;

```sql
SELECT crm._adobeamericaspot5.memberInfo.branchCity as branchCity,
    crm._adobeamericaspot5.memberInfo.branchState as branchState,
    crm._adobeamericaspot5.memberInfo.hasRewardCard as hasRewardCard,
		b._adobeamericaspot5.bankingInfo.mortgage as mortgage, 
		b._adobeamericaspot5.bankingInfo.date as `date`, 
		b._adobeamericaspot5.bankingInfo.numOfAccts as numOfAccts, 
		b._adobeamericaspot5.bankingInfo.points as points, 
		b._adobeamericaspot5.bankingInfo.balance as balance 
FROM crm_fsi crm
JOIN banking b 
ON crm._adobeamericaspot5.personDetails.loyaltyDetails.loyaltyId = b._adobeamericaspot5.bankingInfo.loyaltyId;
```

![](https://adbecdn.azureedge.net/labs/archbee/DataDistillerBase/ScreenShot2023-07-17at8.34.13AM.png)

Next, you will need to expand the query to include a calculation for total based the rate and the number of nights the person will be staying.&#x20;

```sql
SELECT crm._adobeamericaspot5.memberInfo.branchCity as branchCity,
    crm._adobeamericaspot5.memberInfo.branchState as branchState,
    crm._adobeamericaspot5.memberInfo.hasRewardCard as hasRewardCard,
		b._adobeamericaspot5.bankingInfo.mortgage as mortgage, 
		b._adobeamericaspot5.bankingInfo.date as `date`, 
		b._adobeamericaspot5.bankingInfo.numOfAccts as numOfAccts, 
		b._adobeamericaspot5.bankingInfo.points as points, 
		b._adobeamericaspot5.bankingInfo.balance as balance, 
		b._adobeamericaspot5.bankingInfo.balance * b._adobeamericaspot5.bankingInfo.numOfAccts as Total
FROM crm_fsi crm
JOIN banking b 
ON crm._adobeamericaspot5.personDetails.loyaltyDetails.loyaltyId = b._adobeamericaspot5.bankingInfo.loyaltyId;
```

![](https://adbecdn.azureedge.net/labs/archbee/DataDistillerBase/ScreenShot2023-07-17at8.37.26AM.png)

Not that we have joined the two datasets together and we have a calculated total price for the bookings, let's start to expand the query to complete a cart abandonment use case and create a new table with those rows of data.&#x20;

The overall goal will be to create query that will look back 30 days from today and get all the rows that have not confirmed a booking. We will accomplish this by adding a WHERE statement in our query.&#x20;

```sql
SELECT crm._adobeamericaspot5.memberInfo.branchCity as branchCity,
    crm._adobeamericaspot5.memberInfo.branchState as branchState,
    crm._adobeamericaspot5.memberInfo.hasRewardCard as hasRewardCard,
		b._adobeamericaspot5.bankingInfo.mortgage as mortgage, 
		b._adobeamericaspot5.bankingInfo.date as `date`, 
		b._adobeamericaspot5.bankingInfo.numOfAccts as numOfAccts, 
		b._adobeamericaspot5.bankingInfo.points as points, 
		b._adobeamericaspot5.bankingInfo.balance as balance, 
		b._adobeamericaspot5.bankingInfo.balance * b._adobeamericaspot5.bankingInfo.numOfAccts as Total
FROM crm_fsi crm
JOIN banking b 
ON crm._adobeamericaspot5.personDetails.loyaltyDetails.loyaltyId = b._adobeamericaspot5.bankingInfo.loyaltyId
WHERE b._adobeamericaspot5.bankingInfo.date BETWEEN '2024-08-01' AND '2024-08-30'
ORDER BY Total DESC;
```

![](https://adbecdn.azureedge.net/labs/archbee/DataDistillerBase/ScreenShot2023-07-17at8.43.10AM.png)

You have created a query that will show everyone that has booked regardless of confirmation status. You need to add an AND statement to the WHERE condition to add the logic for only including people that have not confirmed.

```sql
SELECT crm._adobeamericaspot5.memberInfo.branchCity as branchCity,
    crm._adobeamericaspot5.memberInfo.branchState as branchState,
    crm._adobeamericaspot5.memberInfo.hasRewardCard as hasRewardCard,
		b._adobeamericaspot5.bankingInfo.mortgage as mortgage, 
		b._adobeamericaspot5.bankingInfo.date as `date`, 
		b._adobeamericaspot5.bankingInfo.numOfAccts as numOfAccts, 
		b._adobeamericaspot5.bankingInfo.points as points, 
		b._adobeamericaspot5.bankingInfo.balance as balance, 
		b._adobeamericaspot5.bankingInfo.balance * b._adobeamericaspot5.bankingInfo.numOfAccts as Total
FROM crm_fsi crm
JOIN banking b 
ON crm._adobeamericaspot5.personDetails.loyaltyDetails.loyaltyId = b._adobeamericaspot5.bankingInfo.loyaltyId
WHERE b._adobeamericaspot5.bankingInfo.date BETWEEN '2024-08-01' AND '2024-08-30'
AND b._adobeamericaspot5.bankingInfo.mortgage = FALSE 
ORDER BY Total DESC;
```

![](https://adbecdn.azureedge.net/labs/archbee/DataDistillerBase/ScreenShot2023-07-17at8.46.57AM.png)

Now that you have the complete list of people that have not confirmed a booking for the last 30 days we can now use an Adobe Defined function to create a table from the select statement that you have created.

```sql
CREATE TABLE notmortgage AS 
	SELECT crm._adobeamericaspot5.memberInfo.branchCity as branchCity,
			crm._adobeamericaspot5.memberInfo.branchState as branchState,
			crm._adobeamericaspot5.memberInfo.hasRewardCard as hasRewardCard,
            crm._adobeamericaspot5.personDetails.loyaltyDetails.loyaltyLevel,
			b._adobeamericaspot5.bankingInfo.mortgage as mortgage, 
			b._adobeamericaspot5.bankingInfo.date as `date`, 
			b._adobeamericaspot5.bankingInfo.numOfAccts as numOfAccts, 
			b._adobeamericaspot5.bankingInfo.points as points, 
			b._adobeamericaspot5.bankingInfo.balance as balance, 
			b._adobeamericaspot5.bankingInfo.balance * b._adobeamericaspot5.bankingInfo.numOfAccts as Total
	FROM crm_fsi crm
	JOIN banking b 
	ON crm._adobeamericaspot5.personDetails.loyaltyDetails.loyaltyId = b._adobeamericaspot5.bankingInfo.loyaltyId
	WHERE b._adobeamericaspot5.bankingInfo.date BETWEEN '2024-08-01' AND '2024-08-30'
	AND b._adobeamericaspot5.bankingInfo.mortgage = FALSE 
	ORDER BY Total DESC;
```

![](https://adbecdn.azureedge.net/labs/archbee/DataDistillerBase/ScreenShot2023-07-17at8.56.42AM.png)

![](https://adbecdn.azureedge.net/labs/archbee/DataDistillerBase/ScreenShot2023-07-17at8.58.33AM.png)

This process will take a few minutes to complete.&#x20;

The query for this will run quickly, but there are other functions being triggered when you use CTAS from Adobe. After it runs the query, it will create a schema. Once the schema is created it will create a dataset. After the dataset it will trigger a dataflow process to insert the data into the dataset. Then the last step is it will create a one time scheduled query for you to review in the UI.

Congrats you have completed the booking abandonment use case using Data Distiller.
