AI for SQL: The Ultimate Data Analysis AI Tool

AskYourDatabase is a revolutionary data analysis AI that will transform how you analyze data! It even generates complex SQL queries for you. In this post, I will demonstrate to you all the features of this AI tool.

Connect with the database

Just like any other data analysis tool AskYourDatabase also needs to connect with your database. It will fetch the data from it and then you can use it like any other AI for data analysis. Let me demonstrate.

Click on “New Conversation” and then “New Connection.” It appears that for the time being, we can only connect with PostgreSQL, MySQL, SQL Server, MongoDB, and Snowflake Database. Let’s choose PostgreSQL.

AI for SQL: The Ultimate Data Analysis AI Tool

Next, select the database—in my case, PostgreSQL—and construct a connection string in the same manner as shown here. Let’s proceed:

postgresql://postgres:postgres@localhost:5432/training_db_v2

When creating this string, be careful with the parameters. In my case, the username and password are “postgres,” the hostname is “localhost,” and I’ve configured it on port number 5432. Additionally, I’m using the database named “training_db_v2,” which I’ve created. In your case, all these parameters could be different.

I’ve created a video series demonstrating how to set up PostgreSQL and create a database in it. If you’re interested, you can watch that.

Click “Connect,” and you will be presented with a ChatGPT-like interface where, instead of writing complex SQL queries, you can chat with the database in natural human language. Let me demonstrate.

Chat with your database

In AskYourDatabase we can interact with our database and request it to generate basic or even complex SQL queries for us. Just like we do with ChatGPT. Let’s begin with simple queries, and then I’ll push its limits to see how proficiently it can craft complex SQL queries.

Let’s begin with basic SQL queries. For the demonstration, I’ll be utilizing the tables Employees, Departments, and Salaries, which are created in the database named training db v2, a demo database I’ve set up in PostgreSQL.

First, let’s quickly examine the structure of these tables.

Prompt: Show me the structure of table names Employees, Departments and Salaries

That was quick. As we can observe, the tables Employees and Salaries have three columns each, whereas Departments has two columns.

AI for SQL: The Ultimate Data Analysis AI Tool

Let’s ask this data analysis AI to generate some SQL code. I’m going to ask it to

Prompt: retrieve the names of employees along with their corresponding department 
names and salaries. 

AI for SQL: The Ultimate Data Analysis AI Tool

Remarkably, AskYourDatabase is quite swift. It displays the query along with the result. Let’s ask it to explain what types of joins it used in the above query and see if it’s not only proficient at coding but also helpful for learning.

Prompt: Could you please explain the types of joins used in the above query?

AI for SQL: The Ultimate Data Analysis AI Tool

Now it’s time to challenge this AI for data analysis with some complex SQL queries. I’m going to ask it the following:

Prompt: Retrieve the names of all employees along with their corresponding department names. 
For employees who have multiple salary records, show the highest salary amount 
they've received. Include all employees, even those with NULL values in the 
 department or salary tables. If an employee has a NULL department, 
 display "No Department Assigned". If an employee has no salary records, 
 display "No Salary Record". Sort the result by department name in ascending order, 
 and then by employee name in ascending order within each department. 

AI for SQL: The Ultimate Data Analysis AI Tool

This is indeed a complex query. Its solution necessitates the use of functions like COALESCE, SQL joins, and subqueries. Let’s see if AskYourDatabase can solve it.

Once again, remarkably swift. It displayed the query and the output.

Data Visualization

So far, we’ve seen how well this data analysis AI works with SQL. Now, let’s see if it can actually perform some business analysis. Can AskYourDatabase assist us in visualizing our data and creating some charts? Let’s find out.

Once again, I’m using this data analysis AI. Next, I’ll ask:

Prompt: Using the 'Employees' and 'Departments' tables, can you create 
a visualization that displays the distribution of employees across all 
departments within our organization? Ensure that the visualization includes 
all department names along the x-axis and the corresponding number of 
employees along the y-axis 

AI for SQL: The Ultimate Data Analysis AI Tool

Ah, it gave us the bar chart exactly as we asked. Amazing.

Let’s try another query:

Prompt: Using the 'Employees' and 'Departments' tables, can you create 
a visualization that demonstrates the average salary for each department 
within our organization? Ensure that the visualization includes all 
department names along the x-axis and the corresponding average salary 
amounts along the y-axis.

Let’s see if it can show us the distribution of average salary this time. Once again, we got the chart as required.

AI for SQL: The Ultimate Data Analysis AI Tool

However, one thing I noticed is that it would be better if we could download these charts for further use. Unfortunately, it seems there is no way to do that. If you find a way, let me know in the comments.

Data Analysis AI with Web App Integration

This data analysis AI is relatively new, and it seems like the team is continually working on it, introducing new features. I’ve learned that you can even integrate this AskYourDatabase into any web app. However, this feature is still in the beta stage. I’m eagerly anticipating using it.

How Can You Configure AskYourDatabase

Setting up AskYourDatabase is incredibly simple. Just visit its website and download it. If you’re using ChatGPT4, you can also grab its extension and start using it. If not, that’s not an issue. You can download its desktop app and set it up. The setup process is straightforward.

While this data analysis AI is a paid tool, you can try it for free. In the free plan, you will receive 100 database queries per month.

I’m excited to see all the plans you have in store for this AI tool. I’m confident you’ll find it incredibly useful. If you want me to explore more AI options for data analysis, analytics, or SQL, just comment and let me know.

That’s it for this tutorial. You can subscribe my YouTube channel for more tutorials on data analysis and SQL. Thanks and have a great day.