0

I am wanting to parse a string within SQL, However, I am not sure how to go about doing so.

Here is my code:

 SELECT distinct sku, A_CLUSTER_DESC 
 FROM TOOL_SAS_DATA 
 WHERE sku in (1099895,
  1099896,
  1000960,
  1000960,
  1000898
  );

My output is:

  ||  sku  || A_Cluster_desc   ||

1 ||1099895|| 'GG SAS AP_1234 A'||

2 ||1099896|| 'GG SAS AP_1113 B'||

etc.

I am wanting to just output under A_Cluster_desc for it to say AP_1234 or AP_1113 and just excluding everything else around it.

EDIT:

Sorry if it wasn't more clear, I am wanting to just output AP_1234 or AP_####

3
  • Is it always going to be of the same pattern like AP_1234 including the prefix and suffix? Commented Feb 8, 2018 at 18:34
  • It will always say AP_ with 4 numbers following it Commented Feb 8, 2018 at 18:35
  • you need ues regexp_substr() and regular expression Commented Feb 8, 2018 at 18:35

1 Answer 1

2

Just for A_CLUSTER_DESC part, use :

select regexp_substr(A_CLUSTER_DESC, '(.*?GG SAS )(.*?) ',1,1,'',2) from TOOL_SAS_DATA;

Demo

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.