Guest User

Untitled

a guest
Jun 20th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. with test_data as (
  2. select 'abc 123' as txt
  3. union
  4. select 'abc 456' as txt
  5. union
  6. select 'blah' as txt
  7. )
  8.  
  9. select
  10. txt,
  11. (regexp_matches(txt, 'd+'))[1] as first_num
  12. from
  13. test_data
  14.  
  15. with test_data as (
  16. select 'abc 123' as txt
  17. union
  18. select 'abc 456' as txt
  19. union
  20. select 'blah' as txt
  21. )
  22.  
  23. select
  24. txt,
  25. (select regexp_matches(txt, 'd+'))[1] as first_num
  26. from
  27. test_data
  28.  
  29. WITH test_data(txt) AS (
  30. VALUES
  31. (text 'abc 123')
  32. , ('abc 456')
  33. , ('blah')
  34. )
  35. SELECT txt, substring(txt FROM 'd+') AS first_num
  36. FROM test_data;
  37.  
  38. WITH test_data(txt) AS (
  39. VALUES
  40. (text 'abc 123')
  41. , ('abc 456')
  42. , ('blah')
  43. )
  44. SELECT txt, (regexp_match(txt, 'd+'))[1] AS first_num
  45. from test_data;
Add Comment
Please, Sign In to add comment