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

    note: 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

    SELECT Category, City, count(*) as "count" FROM "Superstore"
    GROUP BY Category, City
    LIMIT 10;
    
    
    Category City count
    Furniture Akron 2
      Alexandria 3
      Allen 1
      Allentown 1
      Amarillo 4
      Anaheim 8
      Andover 1
      Apopka 1
      Apple Valley 2
      Arlington 13