This is the second part of a 3-part series on segmentation in Salesforce Marketing Cloud (SFMC):
If you want to create a campaign in Salesforce Marketing Cloud (SFMC) that sets you apart, there is a big chance you’ll need to face a complex segmentation process. One of the solutions that SFMC proposes is SQL, Structured Query Language, which is quite an advanced method of segmenting. The creation of queries in SFMC offers a possibility to filter the information in DEs and target in a more sophisticated way.
In short, a query is an activity of getting relevant information from one or multiple data extensions and saving it to a target data extension. The process of SQL query creation is a task that requires some level of experience and time. Moreover, the process of a query activity execution in the SFMC environment can take up to 30 minutes – though this would be the case only for very complex queries.
You need to create a target data extension, which you would like to use for your future campaign. For instance, the data extension below contains four fields that need to be populated with specific information from other data extensions:
In order to create a SQL Query, you should follow the steps below:
Now you can start writing a SQL query:
Note: They have to be separated by a comma except for the last field.
Note: Only selected fields that exactly match the name of the columns in your target DE will be populated.
SQL queries can be very advanced to fulfill all the requirements of a specific campaign. There are many possibilities to adapt the query to your needs.
For creating even more advanced segmentation, you can also use joins. The ‘join’ clause is used for combining data from multiple DEs. Here are four different kinds of joins:
Note: The ‘on’ clause is used to describe how the DEs are related to each other, usually based on an ID or sometimes an Email Address.
After your query is finished and it is validated you can move on to the next step. Here, you need to find your target data extension, which you want to populate with the query. Then decide how you want to add the data:
If you want to do more advanced segmentation on data extensions in SFMC then SQL queries can be an option for you. They allow a lot of freedom and can cover very specific needs. However, it also means that you need to have sufficient technical skills to write those queries. Otherwise, you would need to ask for the help of more technical colleagues (e.g. those in the IT department), which slows down the process of campaign creation or consider a drag-and-drop alternative like DESelect.
Salesforce Marketing Cloud best practices
and DESelect updates