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

Question

Question

workflow custom query

asked on August 15, 2019 Show version history

I'm trying to sort a data source by numbers but my values are stored as strings because they have characters and numbers.

 

Radio ID Column

13E1

13E5

13E8

13E11

13E12

 

Query as written returns (See Pic)

13E1

13E11

13E12

13E5

13E8

 

I want the Query to return

13E1

13E5

13E8

13E11

13E12

 

How do state in query how to sort based off of the last two characters which happen to be numbers and ignore the first 3 characters?  Thanks John

 

Capture.PNG
Capture.PNG (14.7 KB)
0 0

Answer

SELECTED ANSWER
replied on August 15, 2019 Show version history

Ignoring the "13E" alone doesn't get what you need, because you're still sorting strings. You also need to convert the remaining characters to a numeric value. Try something like this:

SELECT
	*
	FROM [Department Roster]
	WHERE [radio id] LIKE @radio
		AND [rank] LIKE @rank
	ORDER BY TRY_CONVERT(TINYINT,STUFF([radio id],1,3,''))
0 0
replied on August 19, 2019

Worked great Scott!  Thanks

0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.