Mastering SQL with Chad GPT

Mastering SQL with Chad GPT

You know what was one of my biggest problems when I started with SQL? In this video, we’ll explore SQL for beginners with Chad GPT to learn it quickly and for free. I’ll also share my battle scars, like real SQL questions from my data engineering interviews, like live coding sessions or home assignments. And I will show you how to use Chad GPT to avoid my biggest problem with them.

Like every great journey, we need a roadmap. Imagine having a clear plan, broken down into two to three-day chunks, taking you from a beginner to a professional in just one month. Let’s see how Chad GPT can fine-tune this roadmap.

Hey Siri, I’m interested in SQL. Create an advanced, detailed monthly plan for studying SQL with two to three-day topic splits. From production to databases in SQL, select statement filtering and sorting data, working with functions, or somehow it didn’t split by the weeks correctly. But the daily split is quite accurate.

But we are not just about the basics. We want the whole enchilada. Advanced topics like outer joins, subqueries, and derived tables, set operations (UNION, INTERSECT), and functions like PARTITION BY. Yeah, now it goes deeply into the topic.

The plan looks great, but how can we deep dive into each topic? Let’s start with day one. I’d suggest using a prominent structure. I want to become a good data analyst. Explain to me extensively the topic of introduction to databases and SQL.

As you can see, prompting each topic in such a manner will give you the information needed. Let’s tackle the next one. Where class? I want to learn SQL. Explain to me the topic of filtering data with WHERE clause comprehensively.

Yeah, here’s a detailed explanation of the WHERE clause, like those attack conditions with the filtering. But hold on, can I just read, right? Let’s get our hands dirty with real-life examples. I want to learn SQL topic for filtering data with WHERE clause. Give me a task with actual data without a solution and expected output.

Okay, so here’s the task for filtering data with WHERE clause. Write the SQL for it to retrieve the employees who work in the IT department and have salary rates equal to or greater than six thousand. Okay, perfect. This is the expected output.

Great! Now, I would suggest you write your solution somewhere else, like Sublime or any text editor, and let’s go back to Chad GPT. Is this solution correct? And paste it. Thank you!

You see how nicely it’s formatted and includes a short explanation? If you’re enjoying this video, like and follow.

Now, let’s move on to something more advanced. Let’s test how Chad GPT is going to perform. I’m interested in SQL. Explain to me comprehensively the topic of advanced joins: left join, right join, full join.

Okay, nice! That’s great. Cool visual examples and code, so you can proceed with that. However, in case you’re stuck and don’t understand what’s going on, you can always use Chad GPT for prompting. Yeah, that famous ’explained to a child’ postfix. So, any of your questions, let’s rephrase the last one. If you didn’t get it correct, I mean, you’ve been SQL. Explain to me comprehensively the topic of advanced joins. Like the child, that’s interesting. It actually uses their example of toys for that. Nice!

Now that we have our study plan, let’s put our knowledge into practice. How to get real-world examples? First, I want to show you the capabilities of Chad GPT in generating its own tasks and solutions. Secondly, I’ll share my battle scars, real SQL questions from my data engineering interviews, like live coding sessions or home assignments. We’ll test how accurately it answers those.

Part one, I suggest using the following formula when you want to practice. You assign the role, define the complexity level of the task, and ask to provide an example of input data. I’m being interviewed for a data scientist role. Give me a medium complexity SQL interview task along with a detailed description and example of input data.

Okay, analyzing sales data. You have been provided with a dataset that contains information about sales transactions. Your task is to write SQL queries to analyze the data and retrieve specific information based on the given requirements. So, this is the input data, the schema of it, and also the requirements. How cool is that?

Now, you wrote your answer and want to compare it. Those match, give a solution to the above query. Worrying? Okay, retrieve the total sales revenue for each product. Yes, calculate the average price. Yes, determine the total quantity sold for each product. Print by products. Some find the customer who made the highest number of purchases. And also, you have a very nice detailed explanation of what’s happening under that. And the last one, write a query to identify customers who placed more than three transactions each in both 2019 and 2020. You have input and the expected output.

Okay, great! The solutions are correct. Let’s move on. Task three, write a SQL query to create a histogram of the number of commands per user in the months of January 2020. There are some notes, like assuming buckets plus intervals. One command by the users that were not created in January 2020 should be counted as zero. Buckets, as it’s a medium complexity task, we don’t even have the example here. So, we only have the input schemas. Let’s say of the user table and comments table. We need to figure out everything ourselves and the output schema.

Okay, so here’s the SQL query. Select command, count(com) as frequency from our CDE group by command count. Okay, what we have here? We have the join of the users table with the commands and also some filtering conditions. Yeah, those are correct. We have the months of January and the year 2020, grouping by the ID and counting the ID numbers.

So, yeah, if you have any kind of questions, you can refer to that or you can again type something when you explain to me that about query step by step. Yeah, and it’s gonna break everything into sequential steps, which you can tackle and read more about it.

Let me share a pro tip. When talking to Chad GPT, be clear, be precise. ‘How does SQL work?’ is a no-go. Try explaining select statements in SQL. Clear doesn’t mean brief or better. Prompting, use prompt method. P stands for Persona, specify the role and expertise or reference. Provide the context, all objective. Define the task, M margins, set clear conditions. Perspective, request multiple outputs. T through output request, clear outputs. E examples, show output examples or refine. Adjust instructions.

Before we wrap up, let’s address the elephant in the room. Chad GPT is not perfect. It can miss syntax errors and may not always offer deep insights into advanced SQL concepts, especially if it’s vendor-related syntax like Snowflake or BigQuery. Therefore, it’s important to consult reliable SQL resources.

And there you have it, dears. A comprehensive plan to learn SQL for free with Chad GPT. My biggest regret is that I didn’t have enough practice examples for particular topics, and I couldn’t generate those. But Chad GPT makes it easier for you. So, remember to stick to the study plan, practice the SQL tasks, use clear prompts, and be aware of the limitations. Together, we can master SQL and unlock a world of data opportunities.

Post your questions below, and here’s the subscribe button. Let’s be friends!

Exploring Machine Learning with ChatGPT
Older post

Exploring Machine Learning with ChatGPT

Newer post

The Power of AI: Embracing the Future

The Power of AI: Embracing the Future