Write SQL in alli audiences
Overview
This document will teach you how to write custom SQL for your power audiences in alli audiences.
Check if you have the ability to edit power audiences here!
Instructions
Follow the steps below once you have created a power audience as per these instructions.
You probably have a couple initial questions running through your head right now, such as:
Where is the audience data stored?
Or, how do I know which table stores which audience data?
Select the lists you will be getting your data for from the CRM List Reference Box. After going through the CRM List Reference in alli audiences document, you should have copied the table ids from which you will get your data. For example: {trans-a2a9dc23-9196-4923-ae93-1c0fb41fea17}
A simple SQL query
The simplest SQL query we could write is one that selects all columns from a single table.
Here is what ours will look like:
![](../../__attachments/3280437383/Screen%2520Shot%25202019-11-25%2520at%25204.48.50%2520PM.png%3Fversion=1&modificationDate=1574722140343&cacheVersion=1&api=v2?inst-v=9d2044ed-f5d2-41ad-960f-0e53811769aa)
In this query, you will notice that we place the entire audience List Reference database table directly into the query.
We will use this style of table formatting for all Power Audience queries.
Go ahead and write your query similar to the above query, with the only change being that you might be querying a different audience list table.
Next click on the Save & Preview button and ensure that you are getting the data correctly populated and getting the correct amount of members.
Before writing any complex power audience SQL queries, go through the requirements for a power audience SQL query.