SQL Query | How many times a substring occurs in a value ? | REPLACE | LEN

preview_player
Показать описание
In this video, we write a query to count the number of occurrences of a substring.

Check out the complete list of SQL Query Interview Questions -

Please do not forget to like, subscribe and share.

For enrolling and enquiries, please contact us at
Рекомендации по теме
Комментарии
Автор

Interesting way of doing it. I think I'd do something like this to avoid the division (not for performance, I just think it's more readable)

jameshogge
Автор

Thanks for your videos.
Note that in MSSQL the Len function excludes trailing spaces at the end of a string. if your input string is like "yes no yes, no yes yes yes" then it will not work correctly.
To avoid this, for example, you can add some character to the end of the input string.

СергейСелютин-юь
Автор

Nice approach by counting length
And I think in Oracle, there is inbuilt function called regexp_count for this.

piyushjoshi
Автор

A simpler solution is using STRING_SPLIT:
GROUP BY value

It's available from SQL Server 2016

nikolaybaranov
Автор

your voice is as same as crackconcept channel girl

gurupradeep
Автор

Hi, please type how to split first and second name from string and make first letter in first and last name in capital.
goodmorning-Good Morning

lkztcpg
Автор

You can execute the query without selecting the sql statements also, just execute 🙂

vijaykumar
welcome to shbcf.ru