Now I need to replace the global GEN by two values F and M, i.e. ::gen=”F, M”; How the Where clause in Select statement identify it as the two values instead of one string value? So how to modify the codes? I tried parse function and it didn’t work.

How to use the global variables in matrix or string format

You can only use the GROUP BY statement if you are grouping the data somehow, i.e. with a Count(*) or SUM() etc. Did you perhaps mean ORDER BY? Just tack it to the end with the || concatenation operator.

sql_string ="SELECT * FROM Big_Class WHERE Big_Class.sex IN " || in_list ||" ORDER BY WEIGHT";