SQL LTRIM

Removes whitespace from the LEFT side only — TRIM's more surgical sibling, for when only one side needs fixing.

What & Why

LTRIM(text) strips whitespace from the beginning of a string only, leaving trailing whitespace (and everything in the middle) untouched.

See How It Works

BUSINESS QUESTION

Product wants leading spaces removed from feedback comments.

iduser_idfeature_idratingnps_scorecommentcreated_at
1101159Clear and useful2024-01-25 12:15:00+00
210224NULLExport worked well2024-02-20 15:40:00+00
3103147Helpful setup flow2024-03-18 09:05:00+00
410433NULLNeeds clearer timing2024-04-08 17:30:00+00
EXAMPLE QUERY
SELECT
  id AS feedback_id,
  LTRIM(comment) AS left_trimmed_comment
FROM product.feedback
WHERE comment IS NOT NULL
ORDER BY feedback_id;
RESULT — exact output from the displayed Queryflo rows
feedback_idleft_trimmed_comment
1Clear and useful
2Export worked well
3Helpful setup flow
4Needs clearer timing

The fixture comments have no leading spaces, so LTRIM preserves them.

Intermediate business practice

Sign up free to try it on a real business scenario