QUERY(tableAndRows, columns)
=QUERY(A1:C10, "SELECT A, B WHERE C > 100", 1)
In this example, the QUERY function is used to retrieve data from the range A1:C10. The SQL-like query selects columns A and B where the corresponding value in column C is greater than 100. The third argument, 1, specifies that the data range includes a header row. The result is a filtered list of data from columns A and B where the condition in column C is met.
=QUERY(A1:D20, "SELECT A, SUM(D) GROUP BY A LABEL SUM(D) 'Total Sales'", 1)
In this example, the QUERY function is used to retrieve and summarize data from the range A1:D20. The SQL-like query selects column A and calculates the sum of column D, grouping the results by the values in column A. The "LABEL" clause is used to rename the header of the summed column to "Total Sales." The third argument, 1, specifies that the data range includes a header row. The result is a summary table showing the total sales for each unique value in column A.
The QUERY function is a powerful tool for working with data in Google Sheets and can be implemented in Sourcetable. It allows for filtering, aggregating, and pivoting data for more efficient data analysis.