Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in BI by (17.6k points)

I have a column of ID's and I am needing to use SQL to extract the first two characters after the " - "

I am using the Custom SQL Query in Tableau 10.4

Example Column:

ABC - BCA - IT

AD - HD - A

QWE - QWE - E

What I need:

BC

HD

QW 

I have tried to use the substring and Charindex function but cannot seem to get it. Any ideas? 

closed

1 Answer

0 votes
by (47.2k points)
selected by
 
Best answer

You can use the following line:

select substring(example, charindex(' - ', example) + 3, 2) from (values ('ABC - BCA - IT'), ('AD - HD - A')) v(example)

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.2k users

Browse Categories

...