high angle photo of robot

ChatGPT for SQL Queries

You might have already tried out ChatGPT. So have I. Today I wanted to share some of my experiences using ChatGPT. For this post, I will share the results of the questions that I had regarding SQL Queries.

I was curious to know if I can get accurate SQL statements. And to my surprise, YES!!

DDL Queries

I decided to try few DDL Statements first.

Question 1: Write a SQL query to delete a table called AP_INVOICES

Question 2: Write a sql query to alter the table ap_invoives and add a primary key called ap_invoice_id_pk on column invoice_id

Here you will notice the additional information provided regarding dropping the existing primary key. I didn’t ask that in my question. However, ChatGPT provided that information. And that is amazing!!

DML Queries

It was now time to test the DML Statements.

Question 3: Write a sql query to convert SYSDATE to MM/DD/YYY format

Question 4: Write a SQL query to view the sum of invoice_amount by invoice_num from ap_invoices table

Conclusion

Based on the above questions and answers you can see that ChatGPT was able to provide accurate SQL statements. What I loved about the interaction was the explanations and the additional details provided for each of the statements.

I believe this is a game changer. And I feel this helping the business users and end users in understanding as well as writing SQL queries on their own. What are you thoughts?


Comments

Questions? Comments? Suggestions? Let us know!! Like / Subscribe / Follow for more updates.