Subsetting example filter clauses
Published 17 October 2023
The --filter-clause argument supports complex WHERE
clauses with sub-queries and joins. Here are a few example scenarios and how the --filter-clause argument looks like.
Contents
10% of sales orders
This is a Sql Server example which takes a certain percentage of a table. This filter works with the worked example.
--starting-table "[dbo].[Users]" --filter-clause "Id IN (SELECT TOP 25 PERCENT Id FROM [dbo].[Users])"
10 random records
This is a Postgres example which takes a certain number of rows chosen at random. This filter will work for any table.
--filter-clause "1=1 order by random() fetch first 10 rows only"
Purchase orders where vendor is from Glendale
This is a Sql Server example which finds all product vendors based in a particular city. It demonstrates a filter containing a subquery.
--starting-table "Purchasing.ProductVendor" --filter-clause "ProductID IN (SELECT ProductID FROM Purchasing.ProductVendor pv INNER JOIN Person.BusinessEntityAddress bea ON pv.BusinessEntityID=bea.BusinessEntityID INNER JOIN Person.Address a ON bea.AddressID=a.AddressID WHERE a.City='Glendale')"
Specify Starting table in config file
StartingTables: - Table: "[dbo].[Users]" FilterClause: "Id IN (SELECT TOP 25 PERCENT Id FROM [dbo].[Users])"