Quick Start: Run Your First Query

Let’s write a basic query for SQL for CRM Analytics in Analytics Studio.

  1. In CRM Analytics Studio, open a Lens on a dataset.

  2. Click the Query Mode button.

    Query mode icon on a New Lens screen

  3. SAQL is the default query language. To use SQL, click Switch to SQL.

    Switch to SQL in Query Mode

  4. Switching to SQL provides a warning that switching clears your current query. If you don’t want to lose the SAQL query, copy it. Then click Switch to SQL.

    Switch Query Mode modal

    To return to SAQL query language, click the Chart Mode button, then click the Query Mode button. If you return to SAQL, you lose any SQL query changes that you made.

  5. The default query for SQL is the row count in your dataset. Let’s update the query to count the number of times a category occurs for each city. To run the query, click the Run Query button. Because we limit the results to 10 rows, the results display the first 10 cities in the furniture category.

    Run SQL query

    CategoryCitycount
    FurnitureAkron2
     Alexandria3
     Allen1
     Allentown1
     Amarillo4
     Anaheim8
     Andover1
     Apopka1
     Apple Valley2
     Arlington13