From the course: Complete Guide to SQL for Data Engineering: from Beginner to Advanced

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Practical example: Debugging real SQL issues

Practical example: Debugging real SQL issues

- [Instructor] Let's walk through a practical example of debugging a real SQL issue using our e-commerce database. Let's just move to our pgAdmin. Assume that we are analyzing our monthly sales figure, but the reported number which we are seeing is unexpectedly low. You suspect there might be an issue with the SQL query, which we are using to analyze our monthly sales. Now see, what could be the problem? Now, this is of a sample query. Let's execute this. Now, when we execute this query, we will see the monthly sales data for every month. What I have done is I used a date truncate function that is getting the month from my timestamp, that is order_month. The SUM is total_quantity multiplied by the price, and then we don't have the price of the item into our order table. So I just try to do the JOIN, and I say JOIN with the product table. And then the condition we have kept is like between 1st January 23 to 1st April 25.…

Contents