You’re almost finished!
Now, we just add the last sub-query, the one for closed deals. This is where we introduce filtering via SQL.
Use the WHERE keyword to start a filter. There are many operators to choose from to filter. Some include, but are not limited to, :
In this case, our code is:
WHERE d."Stage" LIKE 'Closed Won'
Notice how we use the alias for the deals table, and single quotes to specify the filter criteria. Essentially this says, “Include all records for which the stage field (in the deals module) reads exactly ‘Closed Won’.”