Translating and Executing Natural Language Queries

Once your AI Profile has been set on a connection, you can execute natural language queries by executing a statement such as:

SELECT AI <natural language query>

For example (if using the HR schema):

SELECT AI What are the departments and where are they located;

SELECT AI Rank the departments by how many employees work in each department;

SELECT AI Who works in the IT department;

You may wish to follow a workflow where you first translate the natural language to SQL, inspect it, and (optionally) edit the SQL before executing it.

  1. Place the natural language in a commented line (without including the SELECT AI prefix)

    For example:

    -- What are the departments and where are they located
    
    -- Rank the departments by how many employees work in each department;
    
    -- Who works in the IT department;
  2. Place the cursor at the end of the line that contains the commented natural language query

  3. Right click and choose Select AI->Translate to SQL from the menu. Alernatively, you may use the keyboard shortcut or the Select AI toolbar icon.

    The translated SQL will appear.

  4. To keep the SQL in the file, press the tab key. Otherwise it will disappear when you press any key or click elsewhere.

  5. Edit the SQL if desired and then execute it.

  6. To see an explanation of the SQL, place the cursor at the end of the generated SQL and choose Select AI ->Explain from the menu.

  7. To generate both the translated SQL and an explanation, place the cursor at the end of the commented line that contains the natural language query and choose Translate to SQL and Explain from the menu.