Custom functions used in Google Sheets for ease of use and improved functionality.
The Google Sheets Query function is the most powerful and versatile function in Google Sheets.
It allows you to use data commands to manipulate your data in Google Sheets, and it’s incredibly versatile and powerful.
SELECT C, count(B), min(D), max(D), avg(D)
GROUP BY C
ORDER BY avg(D) DESC
LIMIT 3
=QUERY(Data!$A$1:$H$136,"select C, B where B > date '"&TEXT(A1,"yyyy-mm-dd")&"' and B <= date '"&TEXT(B1,"yyyy-mm-dd")&"'",1)
=gsSQL("select invoice, date from booksales where date >= ?1 and date <= ?2", "booksales", booksalesTABLE, true, startDate, endDate)
invoice date
I7202 5/2/2022
I7203 5/2/2022
I7204 5/3/2022
I7204 5/3/2022
I7204 5/3/2022
I7205 5/4/2022
I7206 5/4/2022
This is just a simple example where you need to remember how to format your date in the QUERY.
=gsSQL(
"SELECT books.id, books.title, authors.first_name, authors.last_name
FROM books
INNER JOIN authors
ON books.author_id = authors.id
ORDER BY books.id")
books.id books.title authors.first_name authors.last_name
1 Time to Grow Up! Ellen Writer
2 Your Trip Yao Dou
3 Lovely Love Donald Brain
4 Dream Your Life Ellen Writer
5 Oranges Olga Savelieva
6 Your Happy Life Yao Dou
7 Applied AI Jack Smart
8 My Last Book Ellen Writer
=QUERY( ArrayFormula(
LET(
lt, Books!A2:F10, lt_id, Books!D2:D10, rt, Authors!A2:C6, rt_id, Authors!A2:A6,
look_up, VLOOKUP(lt_id, HSTACK(rt_id, rt), SEQUENCE(1, COLUMNS(rt), 2), 0),
merge, HSTACK(lt, look_up),
FILTER(merge, CHOOSECOLS(look_up, 1)<>"")
)
), "select Col1, Col2, Col8, Col9")
1 Time to Grow Up! Ellen Writer
2 Your Trip Yao Dou
3 Lovely Love Donald Brain
4 Dream Your Life Ellen Writer
5 Oranges Olga Savelieva
6 Your Happy Life Yao Dou
7 Applied AI Jack Smart
8 My Last Book Ellen Writer