Get startedGet started for free

Using the AI assistant

1. Using the AI assistant

You've had your first taste of the AI assistant. In this video, we'll leverage it to generate SQL code and fix some errors.

2. Generate code with AI

When doing this, we should use our own SQL knowledge to verify that the AI output is what we intended it to be. Let's begin with a basic query selecting all rows. Make sure to run this cell so that the information is stored. Now, we'll kick things up a notch. Using natural language, we'll ask the AI assistant to modify the query to show Bob's average sales amount for the clothing product category.

3. Generate code with AI

We can iterate on this and request another filter limiting the results to sales with an average discount above 10 percent. We'll get better results from the AI assistant when we are specific in our request, such as referring to Bob as a sales_rep and specifying the discount as 0.1 instead of 10 percent.

4. Generate code with AI

Here is a close up of the AI generated code. Pretty good!

5. Generate code from scratch

The AI assistant also works when writing a query from scratch, however this is better suited for R or Python rather than SQL, as data loading is more straightforward in those languages. For SQL, it's best to have the data loaded before switching to the AI assistant, as we've seen in the previous slides.

6. Debugging code with AI

Lastly, let's say we've already written our query, which has generated an error. In this case, the output will show a fix and explain button. Clicking this will have the AI assistant review our code and suggest a correction we can accept or reject.

7. Let's practice!

Let's practice using this assistant.