How to use variable in a different SQL variable?

Hi All,
I have a variable named “group” with a simple SQL query that returns me a list of groups from my DB:

SELECT Name
FROM [dbo].[QaHub_Group];

Now, I want to create another variable named “team” with SQL query relays on the “group” query:

SELECT t.Name AS TeamName
FROM dbo.QaHub_Team t
JOIN dbo.QaHub_Group g ON t.GroupId = g.Id
WHERE g.Name = ‘$group’
ORDER BY t.Name;

  1. My example doesn’t work for me; I’m getting an error; what am I doing wrong?
  2. How can I handle a case when I’m selecting multiple groups on the first variable and not only one?
    My “Custom all value” is set to blank.

Click on the query inspector and what does it show for the query

WHERE g.Name in (${group})

1 Like