This task can be performed using SheetQuery
Run SQL on Google Sheets
Best product for this task

SheetQuery
analytics
SheetQuery is the add-on that lets you run SQL directly on your spreadsheets. Combine the flexibility of Google Sheets with the power of SQL to analyze, update, and manage data like never before.

What to expect from an ideal product
- Write SQL queries to join multiple sheets together just like database tables
- Pull data from different sheets into one view without complex formulas
- Match and merge rows from separate sheets based on common columns
- Create custom combinations of data using WHERE and GROUP BY clauses
- Save your queries as views to quickly refresh combined data whenever needed