Postgres: extract integer prefix

SELECT CAST( SUBSTRING('123 test test' from 0 for POSITION(' ' IN '123 test test')) AS INTEGER)
-> 123
SELECT TRIM(LEADING ' ' from SUBSTRING('123 test test' from POSITION(' ' IN '123 test test')+1))
-> 'test test'

--

--

--

Software Engineer @ London [https://www.linkedin.com/in/elvisciotti]

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

KfExplorer — Kafka Manager For MacOS

Server-less Cloud Computing using Microsoft Azure

I’m so excited to introduce you guys to Jeremiah Saunders a biz owner from San Diego, CA!

Analyzing SCOTUS votes (part 1): Scraping wikipedia tables

source: https://en.wikipedia.org/wiki/1999_term_opinions_of_the_Supreme_Court_of_the_United_States

How do Andon and escalation differ?

Capturing Data Electronically in Clinical Research with PERFEQTA

Features, but faster: the life of an Android developer at Badoo

Azure Boards: How To Get Started With Agile Planning on Azure?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Elvis Ciotti

Elvis Ciotti

Software Engineer @ London [https://www.linkedin.com/in/elvisciotti]

More from Medium

Apache Kafka Guide

Matching PostgreSQL Data Types into Java

Basic NoSQL Queries used in MongoDB

MongoDB Iceberg: Introduction to MongoDB Query.