Pick a student name from a dropdown -> show data points related to that student below

I connected Snowflake to Retool and am working on some queries. New to both tools so doing some learning, bear with me!

I got this query going to get student names into a dropdown:
SELECT DISTINCT STUDENT_LAST_NAME from PUBLIC.PLATFORM_ACTIVITY_BY_STUDENT_HISTORICAL ORDER BY STUDENT_LAST_NAME ASC

Then using the last name selected in the dropdown, pull in specific student info (this one isn't working):
SELECT PROJECT_SCORE_PERCENT,NUM_PFAS_BEHIND,NUM_PROJECTS_OVERDUE from PUBLIC.PLATFORM_ACTIVITY_BY_STUDENT_HISTORICAL WHERE STUDENT_LAST_NAME = '{{ studentLastName.selectedItem.STUDENT_LAST_NAME }}'

I've made sure there is data for the names I tested with. No data shows regardless of the name picked.

Any idea what I'm doing wrong?

Thanks so much!

@buddhs Welcome to the forum!
Is {{ studentLastName.selectedItem.STUDENT_LAST_NAME }} correctly interpreting the selected Item? Can you try {{studentLastName.value}} instead?

Hi @ScottR, thanks!

{{studentLastName.value}} didn't do anything either. When I hover over it, it correctly shows the selected student's name as value (it did so with my longer version above too.)

When I run the query no rows return.

I also see this:
image

The query that populates the name is going to the same source, so this is confusing..

Take a look at this:

Interesting, thanks!

So I set up a text label and then used the value that's displayed there in the query (instead of the dropdown value), and now the query works!

Why does that make a difference?

because in your query you should be referring to the "selectedLabel" of the dropdown because it seems the label and value in each option of the dropdown are NOT the same. - I don't know and am only assuming because I have limited insight into your application