Trying to use sql to select distinct values from column

  • Very new to sql but trying to figure out if i can use sql to select just values in column "Ctrl" that start with "R".

     

    In this data set all i need is the "R-######" and nothing else but cant figure out how to get it. Any help would be much appreciated. Thank you!

     

    See attached for data table

    • This topic was modified 5 years, 4 months ago by  dsb1933.
    Attachments:
    You must be logged in to view attached files.
  • LIKE

     

     

  • or LEFT

    --Vadim R.

  • rVadim wrote:

    or LEFT

    LEFT is never SARGable.  LIKE is SARGable if the pattern begins with a constant.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • If you specifically want "R-" followed by 6 digits, you could do:

    YourColumn LIKE 'R-[0-9][0-9][0-9][0-9][0-9][0-9]'

     

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply