Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
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)

Related questions

0 votes
1 answer
0 votes
1 answer
asked Aug 27, 2019 in BI by Vaibhav Ameta (17.6k points)
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...