Home > Back-end >  Write a query to find 2nd best word from the string using sql
Write a query to find 2nd best word from the string using sql

Time:10-01

I have below table like this:

ID      Name
1       Ram played best And he best one
2       Shiv is best in reading and he is best player
3       X is best cook

I need to get the output like this:

ID     Second best word
1      one
2      player
3      n/a

I need to get the output whatever we have after 'best' word in the name string. Can anyone help me to crack this?

CodePudding user response:

You can use the following;

select
    id,
    name,
    case
        when PATINDEX('           
  • Related