Query to return the value that comes before a specific character

1

I have a table called answer that is filled with answers to certain questions, each answer usually starts with the letter that would be the answer, for example: a)..., b)..., c)... ou d)..., The problem is that it does not always start like this, with a html code to return the response letter, it can be <p>a)...

I would like a query that returns only the letter that comes before the parenthesis ) , also remembering that it should only take the value that precedes the first parenthesis, if other parentheses may appear in the answer.

I'm using it like this:

Select substr(answer,1,1) AS resposta

But it will not do if something else comes before the response letter.

    
asked by anonymous 20.03.2018 / 13:23

1 answer

2

Follow the idea commented by Rovann , use position() :

SELECT substr (answer_column, (POSITION (")" IN answer_column) - 1), 1) Answer

    
20.03.2018 / 13:35