google-sheets icon indicating copy to clipboard operation
google-sheets copied to clipboard

Execute SQL SELECT statements on sheet data.

Open demmings opened this issue 2 years ago • 0 comments

  • An enhancement over the Google Sheets QUERY() function.
  • All common SQL SELECT syntax is supported.
  • For more information about using: https://github.com/demmings/gsSQL
  • Basic use:
=gsSQL( SelectSqlStatement, [TableDefinitions], [ColumnOutputFlag], [BindVariableData])
  • SelectSqlStatement ==> Your SELECT statement.
  • TableDefinitions ==> "table1", range, "table2", range,...
  • ColumnOutputFlag ==> true/false. Include column names in output.
  • BindVariableData ==> As many variable data items that are referenced in SELECT. The first one is replaced in SELECT as ?1. The second one is ?2, and so on...
select * from sales where date > ?1
  • Example:
=gsSQL("select transaction_date, sum(gross), sum(amount)
          from 
             mastertransactions 
          where 
             transaction_date >= ?1 and transaction_date <= ?2 and expense_category in
           (select income from budgetCategories where income <> '') 
           group by 
               transaction_date pivot account", 
           "mastertransactions", 'Master Transactions'!$A$1:$I, "budgetCategories",budgetIncomeCategories,
 true, '01/01/2022', '05/19/2022')

demmings avatar Mar 16 '23 00:03 demmings