Hi all, I’m running an SQL query (inside a sql block) that returns an id with info that is passed to plot. In addition to plot, I’d like to extract the last record from the table, and show a specific value inside a div.
# a sample SQL query -- anything really would do at this stage
'''sql id=test
select
'hello' as key,
'world' as value
union all
select
'howdy' as key,
'partner' as value
'''
# do some other plot here.
..
# show me the last row from the list, and pull out a specific value
<div class="grid grid-cols-1">
<div class="card">${test[-1].value}</div>
</div>
One way is to run another SQL query that retrieves the one value alone. This works, however I’m trying to reduce the amount of SQL that needs to run to ensure the code is easily readable and maintainable.
Any suggestions on how I can get this value?