Generate SQL and SOQL queries

Overview

You can use SnapGPT to generate SQL or SOQL queries in Snaps that have a SQL or SOQL query text box.

SnapGPT uses the natural language sentences that you provide to generate SQL or SOQL queries using LLMs.

Currently, only the natural language sentences that you provide are used. The column and table names that are used in queries might be inaccurate because we do not use customer data to generate the queries. In the future, SnapGPT may use your database or endpoint schema to generate more accurate queries.

  1. Open a Snap that supports SQL or SOQL queries and open SnapGPT.
    For example, if you open the Salesforce SOQL Snap, the suggestion Create SQL query appears above the SnapGPT prompt.
  2. Click Create SQL query to generate an example prompt.
    Note that the example prompt is highlighted.
  3. Replace the highlighted text in the prompt with what you want SnapGPT to generate.
    In this example, we replaced the highlighted text with get the total amount of opportunities closed within the last quarter grouped by account's country and stage

    Tip: To achieve more accurate results, specify your column and table names for the query in the SnapGPT prompt.
    SnapGPT generates the query and displays it in the SQL Preview panel.
    Preview panel with SQL query

  4. Use the preview panel to review the generated query and edit it if necessary.
  5. Verify that the column and table names are correct.
  6. Click Apply to Snap if you want to incorporate the generated expression.
    The query displays in the Snap UI.
    Salesforce SOQL settings with SOQL query