๐ How To: Generate a SQL Query
Once a database has been setup in AI Query, we are ready to start generating SQL queries. Let's take a look at how to generate SQL queries.
Steps
On the AI Query Dashboard, navigate to Query Playground and
select the Database.
๐ก
For example purposes we will use the Demo database.
Select Create Query as the Query Type for the Query Prompt.
Below is a Query Prompt we want to use to generate a SQL Query:
Query Prompt
get all customers with more than 10 ordersNow click โถ to generate the SQL Query .
SQL Query
SELECT c.customer_id, c.first_name, c.last_name, COUNT(o.order_id) AS order_count
FROM Customers c
JOIN Orders o ON c.customer_id = o.customer_id
GROUP BY c.customer_id, c.first_name, c.last_name
HAVING COUNT(o.order_id) > 10;You'll see that you get a SQL Query generated based on the Query Prompt you specified! ๐