Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Given Letter, Get Next Letter in Alphabet

I have letter "a", "b", "c". I would like my results to be "b", "c", "d" in TSQL respectively. Would what I use to achieve this?

like image 532
Lloyd Banks Avatar asked Aug 29 '12 13:08

Lloyd Banks


People also ask

What letters is next to L?

The English Alphabet consists of 26 letters: A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z.

How do I get the next letter in SQL?

Use ASCII to get the value of the character, add one, and use CHAR to convert the value back to a character. Save this answer.

How do I get the next letter in C#?

Try this: char letter = 'c'; if (letter == 'z') nextChar = 'a'; else if (letter == 'Z') nextChar = 'A'; else nextChar = (char)(((int)letter) + 1); This way you have no trouble when the char is the last of the alphabet.

How do you get the next character of the alphabet in Python?

To increment a character in a Python, we have to convert it into an integer and add 1 to it and then cast the resultant integer to char. We can achieve this using the builtin methods ord and chr.


1 Answers

Use ASCII to get the value of the character, add one, and use CHAR to convert the value back to a character.

SELECT CHAR(ASCII('a') + 1)
like image 162
Jonathan Wood Avatar answered Sep 25 '22 08:09

Jonathan Wood