• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 272
  • Last Modified:

What is the function Substring doing SUBSTRING(CUST_ID.ID_DESC, 3, 2) AS Terr,

Can someone give me a greakdown of what it is doing.
Fletcher Burdine
Fletcher Burdine
2 Solutions
Brian CroweDatabase AdministratorCommented:
Extract a string 2 characters long from the CUST_ID.ID_DESC column value starting with the third character.

You should take a look at Substring - MSDN

This in your code takes three parameters, first one is the expression in your case its the column "CUST_ID.ID_DESC", the second parameter is the start index, Which is 3, and the third parameter is the number of  characters to be retrieved. Consider the following exmple

SELECT SUBSTRING('Test value', 3, 2) AS Terr

Open in new window

This would return "st", since the index starts with `1`, (not 0 like C# or Java), at index 3 it finds "s" and from that position in takes 2 character so the result is "st" and the returned column is aliased as "Terr"
Fletcher BurdineTableau Trainer & Consultant Sales Exec.Author Commented:
That is exactly what I thought it would do. Just wanted to verify from the experts. Never hurts to hear it from the pros.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now