Date: August 2, 2022
Provide the name of the sales_rep in each region with the largest amount of total_amt_usd sales. Step 1 – Get the MAX total_amt_usd per region: regionname totalamt Midwest 48675.90 Southeast 95005.82 Northeast 93106.81 West 232207.07 I get the max amt_usd per region, but how do I get the name of those reps with this total sales? I am trying another approach below. I … Read More
Date: July 31, 2022
Quiz What is the top channel used by each account to market products? How often was that same channel used? However, we will need to do two aggregations and two subqueries to make this happen. Let’s find the number of times each channel is used by each account. So we will need to count the number of … Read More
Date: July 31, 2022
Simple the inner subquery is completely independent from the outer query Correlated the inner subquery is dependent on a clause in the outer query The second concept to consider before writing any code is the dependency of your subquery to the larger query. A subquery can either be simple or correlated. In my experience, it’s … Read More
Date: July 31, 2022
Inline Subquery creates a table that you could then query again in the FROM statement Expert Tip Note that you should not include an alias when you write a subquery in a conditional statement. This is because the subquery is treated as an individual value (or set of values in the IN case) rather than as a table. Nested and … Read More
Date: July 30, 2022
The first concept that helps when thinking about the format of a subquery is the placement of it: with, nested, inline, or scalar. The second concept to consider is an indentation, which helps heighten readability for your future self or other users that want to leverage your code. Badly Formatted Queries Though these poorly formatted … Read More