How to sort data from SQL query

Hi!

How can i only output i.e the [BrewDate] from this query?

The best way is to create a new named query with only one column.

SELECT TOP 1000
    [BrewDate]
FROM ...

Alternatively, you can use an expression transform as you are doing.
columnRearrange({value}, 'BrewDate')
but this may be slower than using the correct query in the first place.

https://docs.inductiveautomation.com/display/DOC81/columnRearrange

1 Like

Thank you, this seems to work. Only problem it how can i format the result? Now it shows like this:

image

I want it to show "American Blonde".

Thank you :slight_smile:

You have a 1000 row binding on a label which can only display one piece of text. Your query indicates that you are expecting that many results but your result above shows that you only got one. Is there something else wrong?

To show one value in the label change your named query to Scalar query type (which just returns a single value) and use

SELECT TOP 1
    [BrewDate]
FROM ...

ORDER BY [BrewDdate] DESC

if you want the most recent BrewDate (otherwise what you get will be kind of random depending on the order of the records in the DB).

If you want to display more than one then bind your original query to a table component instead.

You can right-click on the label.text binding, copy binding, right-click on the table data property and paste binding there.

2 Likes