Link to home
Start Free TrialLog in
Avatar of Aubrey Marishane
Aubrey Marishane

asked on

A function in SQL that looks for occurrences of certain characters in a field and returns a certain string

For example as per attachment, i would like a  function that looks at a single occurrence of females first on the management level field and Gender field and gives an additional column a label for example VP Black women, and at the same time look at the occurrence of both male and female and the management level and gender field and give a label/column field of for example VP Black. I would like to use this label or column in SSRS to show a field grouped by females only and a combination of males and females. Your assistance will be highly appreciated.

for example, the query i had in mind would go like this. Excuse i am a complete novice

select [Management level],[gender],[Corporate grade]
case when patindex(%Black%,[Management level]) AND patindex(%Female%,[Gender key]) the 'VP Black women' else 'VP Black'
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

I would suggest you having the mapping tables so that you can easily join them in the Select SQL statement and get the results you wanted.
no attachment providfed... very confusing...
better create an excel, put some demo data and show what you need out of this data
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.