I am trying to get all lines in some SQL code between WHERE and GROUP, I have the below, which gets me the first occurrence of text between WHERE and GROUP, but there are multiple occurrences of the same I am after
awk '/WHERE/{p=1} p; /GROUP/{exit}' filename.txt
Output
WHERE something
Some SQL code
GROUP BY something
There are multiple sections of the code that start with WHERE and end with GROUP BY with in the file I would like to output
Can anybody help?