Accessing Individual Values from a Single-Row Query Variable in PostgreSQL

I have a query variable that returns a single row of values from a PostgreSQL database. Is it possible to extract the first or second value from this variable directly for use in further query?


Consider the following query:

SELECT name FROM users;

This would return

This query returns a single row : name. I’d like to access the name value directly, if possible.

Specifically, I’m wondering if I can use syntax like ${Query.[0]} to achieve this, as opposed to adding the names as a filter on a dashboard.

So in the visualization, i could query

SELECT last_login
FROM logintable
WHERE user = ${Query.[0]}

And it would give me all of John’s login and ${Query.[1]} would give all of Wick’s login so on and so forth.

I’m open to using alternative approaches if direct indexing isn’t feasible.
Thank you for any insights or suggestions!

Welcome @vishnudroidpro

What is the end goal of doing this approach? A different panel for each user?

Hi Yosiasz.

In the same panel, I would like to add the same query but for different users and show then simultaneously.

i have also a ZTNA network access database for a few URL’s that would also need to be plotted over time.

SELECT last_access as time, url FROM Internet_url_cache where user = ${Query.[0]}
and so on and so forth for all users at the same time.

I dont think you can do the above as far as I know