Louri,
Check your syntax. It's a good idea to test your SQL statement outside of Opus if you are new to DB and SQL. If it works directly, I find it easy then to copy the proven sql statement into OpusScript (between quotemarks).
When you start working with Opus variables inside the SQL statement, it is simply a matter of using the '+' operator for concatenation of the strings and the variables. There are several examples if you do a search on the forum.
Your question seems to be specifically on SQL and its capabilities?
viewtopic.php?t=3005&highlight=sql+syntax
For some tutorials on sql, try these:
http://www.java2s.com/Code/Oracle/CatalogOracle.htm
http://www.1keydata.com/sql/sql.html
The 'group by' option in SQL is usually applicable if you are working with numeric values which are summarized in some way, or you want to output some specific formatting for a report. You don't give much info on the specifics. Hope that helps.