Day 2: DOCUMENTING MY SQL PROGRESS
Just another day in the trenches, Chads.
Couple of queries today. Each query is separated by comments.
Query 1: All orders placed in the last 90 days from today's date. The idea here is to use the DATEADD function to add 90 days to the current date (GETDATE() function). The WHERE clause is then checks if a particular order date falls between today and 90 days ago (90th day inclusive due to the >= operand), it's record is returned.
Query 2: Customer details are returned based on their spending level. Poor people like
@Dolypizo can be found in the 'Low Value' category. While rich men like
@uptown_analyst0 are in the High value category. All figures in dollars of dollars. The INNER JOIN is used here to connect the customers and orders table and of course the CASE statement is used to define conditions
-- FRAME TWO --
Query 3: This query classifies products by the number/amount left in stock. The CASE statement is used for categorization.
Query 4: This query returns all orders alongside the details of the customer that placed these orders. Classic use of the INNER JOIN. TBH, I instinctively want to use the INNER JOIN before I use any other JOIN type. Is this way of thinking flawed? Please let me know, so I stop fooling.
--FRAME 3--
Query 5: This query provides a clear report of each product along with the the quantity sold. From the result observed, Iphone 15 is the top product sold. I used the COALESCE function to add up for products that have not been sold yet. I reckon these products will be left out without the COALESCE function?? Need to confirm that!!
Query 6: This query returns results for all the customers who have placed orders but have not left any review. Based on results, such customers are not really many in this dataset. These kind of customers could prove problematic for a business, if it cannot determine customer satisfaction for business improvement. I guess such businesses have to focus on received reviews.
I actually need feedback. Let me know If I am caping with these queries or they are not optimized for efficiency. I will engage your posts too, Abeg. 😂
So that's it for DAY 2. See you tomorrow!
#DataScience #dataengineering #datanalysis #SQL #sqlknowledge #sqlbeginner