I am using BigQuery and need help finishing my query.
We have a dataset of Order numbers that have a few issues (This is what I want to achieve)
| OrderNo | Outcome |
|---|---|
| 18446 | 18446 |
| 19628@00 | 19628 |
| 12345.1 | 12345 |
| 12345.2 | 12345 |
I can get the "@00" removed but I can not get the decimals removed to get a single OrderNo when I have a decimal included. (They use the decimal for sub Jobs)
SELECT
ORDERNUMBER,
Case
when regexp_contains(ORDERNUMBER, "@") then regexp_extract(ORDERNUMBER,"(.*)@" )
when regexp_contains(ORDERNUMBER, ".") then regexp_extract(ORDERNUMBER,"(.*)." )
else ORDERNUMBER
end as Outcome
FROM `JOBHEADER`
I tried escaping the "." with \ and / but I have no idea how to find it using regexp
