You are viewing limited content. For full access, please sign in.

Question

Question

Query an SQL table and find the maximum number in a column

asked on June 28, 2017

In workflow I want to query a table and in one column find the maximum number in that column.  Any ideas?

0 0

Answer

APPROVED ANSWER
replied on June 28, 2017 Show version history
SELECT COUNT(YourFieldNameHere)
FROM YourTableNameHere

^^that will give you the total number of rows in the column

SELECT MAX(YourFieldNameHere)
FROM YourTableNameHere

^^that should give you the highest value in your column.

 

0 0

Replies

replied on June 28, 2017

If you're asking what I think you're asking, first you want to create a multi-value token, then do your query, then in a For Each Row add each value to the multi-value token (append).

Next, use the token editor and apply the Max function to the token with all your values; this will result in the "largest value" in the multi-value token.

 

There's actually a bunch of ways you could do this; one alternative for example would be to use a normal token with a default value of 0, then have a conditional sequence in the For Each Row loop that check each value and replaces the token if the current value is higher:

  • If CurrentValue > TokenValue
    • TokenValue = CurrentValue
0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.