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)

Browse Categories

...