Steps to execute different queries
Step 1: Create table in PostgresSQL through this query.
Step 2: Now create new Grafana dashboard and select database in my case(Postgres) selected and then select Stat visualizations.
Step3: Create variable and select variable type custom and give custom options in my case(ie.10,20).
Step 4: In code area execute the query shown in screenshot for execution different queries depending on custom variable value.
Final Output for value 10 selected.
Final Output for value 20 selected.