“As I stood at the edge of the bustling city, the sun was just starting to peek over the horizon. The sky was awash with vibrant colors, and the air was filled with the sound of people waking up to start their day. I could feel the excitement and energy in the air, as if the city itself was pulsing with life. I knew that this was the beginning of something big. The world was about to change in ways that nobody could have predicted, and I was lucky enough to be here to witness it.”
This is the first bit of text ChatGPT, a large language model and artificial intelligence technology, trained by OpenAI that allows you to have natural, human-like conversations with a computer, writes to me when I ask it to “write a story about standing at the dawn of a revolution”. It might do so a bit dramatically, but it does describe some of my feelings about ChatGPT, and I think somewhere inside you it also tingles your senses.
It feels like yesterday but it was two years ago that GPT-3 was released. Wikipedia describes it as “an autoregressive language model that uses deep learning to produce human-like text.” I was blown away by its capabilities and as you might expect from technology like this, it is advancing exponentially. As it is outside of the scope of this article, I encourage you to lose yourself in finding out more about it.
ChatGPT is based on GPT-3.5 and has piqued the interest of many over the past week. It feels to me like the possibilities are endless. For example, I now want to explain to you why people are intrigued by ChatGPT. Instead of doing it myself, I can ask ChatGPT to do the explaining and it will generate a completely original text. If its response is too long for me, I can tell it to make it shorter and it will give a new, more concise, output:
“People are intrigued by ChatGPT because it allows them to have natural conversations with a computer. It is a revolutionary technology that has the potential to change the way we interact with computers. ChatGPT is a large language model trained by OpenAI, which means it has been trained to understand and generate human-like language. This allows it to have engaging and intelligent conversations on a wide range of topics. As it has more conversations, it continues to learn and improve, making it an exciting and innovative technology.”
The fact that it continues to learn and improve can take some getting used to. When I asked it to write the story in my introduction, it began talking about itself and how it is the sole reason for the revolution. I found out that, because I talked with it about ChatGPT before, it used this as a topic for the revolution. While this was clearly a false alarm, it does adhere to the attitude of some people fearing the advancement of artificial intelligence. It is not without reason and the discussion about the future of artificial intelligence seems to be never ending.
I ran to the office this week, excited to test what ChatGPT is capable of in the Data Science field. When reading the documentation, I came across the possibility to help with SQL queries. At the office we played around with it but also quickly got lost in the boundless possibilities when it comes to creative writing. So who better to give an explanation of how ChatGPT can help in the Data Science field than ChatGPT itself! Hence, I gave it the prompt “Write a LinkedIn blogpost about how ChatGPT can help data scientists write SQL queries and give an example of a complicated SQL query generated through ChatGPT”.
It handed me a perfectly fine blogpost as requested but the example query was quite simple: a select statement with one aggregate function and a where clause. I wanted to show that ChatGPT is capable of doing way more so I asked it to make the blogpost a little longer and complicate the example queries a little further, multiple times. The result can be found below.
The result
Hello LinkedIn community!
As a data scientist, writing SQL queries can sometimes be a tedious and time-consuming task. But what if I told you that there’s a tool that can help you write complex SQL queries quickly and easily? Introducing ChatGPT, a natural language processing tool that uses cutting-edge machine learning technology to generate SQL queries from simple English language instructions.
Here are a few examples of how ChatGPT can be used to generate very complex SQL queries:
Suppose you want to find the average salary for all employees in the “sales” department who have been with the company for more than 5 years, have a job title of “Manager” or “Director”, have a degree in computer science, and have a salary greater than the average salary for their department. With ChatGPT, you can simply provide the following instructions:
“Find the average salary for employees in the sales department who have been with the company for more than 5 years, have a job title of Manager or Director, have a degree in computer science, and have a salary greater than the average salary for their department”
And ChatGPT will generate the following SQL query:
Or suppose you want to find the total number of orders placed in the month of June that were for more than $100, were shipped via FedEx, and were placed by a customer with a VIP membership. You can provide the following instructions to ChatGPT:
“Find the total number of orders placed in June with a total value of more than $100 that were shipped via FedEx and were placed by a customer with a VIP membership”
And ChatGPT will generate the following SQL query:
You can even use ChatGPT to find the top 10 highest-earning employees who are based in the state of California, have a job title of “Manager” or “Director”, and have a salary greater than the average salary for their department. Simply provide the following instructions:
“Find the top 10 employees with the highest salaries who are based in California, have a job title of Manager or Director, and have a salary greater than the average salary for their department”
And ChatGPT will generate the following SQL query:
As you can see, ChatGPT is able to quickly and accurately generate very complex SQL queries based on detailed English language instructions. This can save data scientists a lot of time and effort, allowing them to focus on more important tasks.
Overall, ChatGPT is a valuable tool for data scientists looking to streamline their SQL query writing process. Give it a try and see how it can help you!
After reading the above, I hope the ‘dawn of revolution’ story and the feelings that accompany it make more sense. I will not spare you its final paragraph:
“As I stood at the edge of the city, watching the sun rise over a world that had been forever changed by ChatGPT, I couldn’t help but feel a sense of awe and wonder. We were standing at the dawn of a revolution, and I was grateful to be a part of it.”
Follow The Data Story on LinkedIn to stay up to date on our blogs and more!