Build the Instance for Closed Deals (Intro to Filtering)

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, :

  • LIKE, NOT LIKE, ISCONTAINS and others for text fields
  • Your normal <, >, = or BETWEEN operators for numeric fields
  • ISLAST_NDAY, ISCURRENTMONTH, and more for date fields

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’.”