BeyondRelational.com is back with another challenge this week. This challenge is all about counting the number of occurrence of characters in a string using a SET based query. The task is to list all the characters and count of that character within the given string
Challenge URL: Count the Number of Occurrence of Characters in a String
I had written a similar article sometime back which can give you some hints on how to solve the challenge. Check the article here Count Occurrences of Characters in a String – SQL Server
DECLARE @longWord varchar(28)='AntiDisEstablishmentArianism'
SELECT CountCharacters =
- DATALENGTH (REPLACE(REPLACE(LOWER(@longWord),'a',''),'i',''))
Remember the code shown above is just a hint on counting character occurrence and not the solution. Read the challenge and its rules carefully over here.
Did you like this post?
|subscribe via rss||subscribe via e-mail|
|print this post||follow me on twitter|