I am new to SQL and need to query a database to extract certain information before I can import it into another software I am familiar with to analyse the data. The table I am trying to query has information that looks like below:
MV: Gone Girl (2014)
BT: USD 61,000,000
CP: Twentieth Century Fox Film Corporation, Regency Entertainment (USA), Inc.
GR: USD 167,735,396 (USA) (8 February 2015)
GR: USD 167,590,676 (USA) (25 January 2015)
GR: USD 37,513,109 (USA) (5 October 2014)
GR: USD 167,761,501 (USA)
I would like to extract the information in the lines that start with GR, and I would like to organize them into four columns;
- currency,
- amount,
- country,
- date.
After spending a lot of time I have now put together the following code (I know it is not an elegant way of doing it), but it does not grab the information in the last line because it is missing the date information. I would like the date column to be empty for the last row, but still extract all the other information.
regex_match '(?:GR:[ ]([A-Z]{3})[ ](\d{1,3}(?:[,]\d{3})+)[ ][(](USA)[)][ ][(](?:|\d{1,2}[ ]\w+[ ]\d{1,4})){1}','g')
I would be grateful if someone could help me to fix my code.