Merge two queries into one table

Can you please tell me how to combine two tables into one?
The main query is A.
The auxiliary query is B.

Query A has Logins.
Query B has fewer logins.

If a login from query A is contained in query B, then it should be opposite in the table (as on the screenshot).

If the login from query A is missing in query B - leave the field empty.

Finally, I want to display the last column this way:
Any login = Display “Yes”.
Empty cell = Display “No”

current transformation. I understand this transformation doesn’t do much right now. But what can be used next?


What is your data source?


Which version and are you using influxql or flux query language to do the query? Please also provide sample data.


query A, format as table

SELECT last("count") FROM "VDIUsersAndCompanies" WHERE ("organization" =~ /^$Company$/) AND $timeFilter GROUP BY "displayname", "login", "organization"

query B, format as table

SELECT last(sessionstate) FROM "horizonMachines" WHERE ("username" !="") AND time > now()-42d GROUP BY "username"

Grafana 9.0.5
Influx 1.8.4

The queries you showed us her do not match your original question details. In original post you talk of logins here you show us count and date.

Please provide sample data as csv



My mistake.
I added alias “username” to login and used transform “outer join” instead of “merge” and it worked.

1 Like