Can ChatGPT Write Better SQL than a Data Analyst?

Create image :- google

Tried ChatGP, a variant of the GPT-3 language model specifically specified for generating human-like text in conversation.

Create image :- google

ChatGPT even explains what it did. I don’t find the query very readable — one of the reasons why I love common table expressions is readability — but let’s see how it performs.

Create image :- google

This game will be based on 3 LeetCode SQL challenges (one easy, two medium). I will write every solution first, and then send the exercise to ChatGPT and see which solution works best.

Create image :- google

Impressively, it works, but it is slower than my result. Although I am glad to do better than ChatGPT, I would have loved to know how I can improve this query.

Create image :- google

We both made a mistake in this challenge and both were able to fix it (although I had to give a hint to ChatGPT). 

Create image :- google

 I had a slightly better result in terms of runtime, so point goes to me but it was close!

Create image :- google

I was still impressed by its abilities, and amazed that it is able to correct its mistake! ChatGPT definitely beats me on speed; it writes valid SQL syntax in a few seconds, whereas I need a few minutes.

Create image :- google