Skip to content
Advertisement

How to use a SQL query in Google Sheets to group by a substring

In my table, in Google Sheets, I have a column B called “description” and I’m trying to write a SQL query to group by substrings of column B. Values in B are like “Sell 1 Jan11 300.0/307.5 Strangle” and I just want to group by ‘Jan11’. I have a few rows with Jan11 then it switches to Jan18, etc.

I’ve tried substring, char index, mid, and nothing is working I’ve tried:



I’ve gotten a parse error that says

“Unable to parse query string for Function QUERY parameter 2: PARSE_ERROR: Encountered ” “(” “( “” at line 1, column 14. Was expecting one of: “where” … “group” … “pivot” … “order” … “skipping” … “limit” … “offset” … “label” … “format” … “options” … “,” … “” … “+” … “-” … “/” … “%” … “” … “/” … “%” … “+” … “-” …”

Advertisement

Answer

your tries are not valid syntaxes. try like this:


0

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement