Sorting SQL by first two characters of fields

后端 未结 5 442
一生所求
一生所求 2021-01-18 08:01

I\'m trying to sort some data by sales person initials, and the sales rep field is 3 chars long, and is Firstname, Lastname and Account type. So, Bob Smith would be BS* and

5条回答
  •  心在旅途
    2021-01-18 08:41

    You haven't said what DBMS you are using. The following would work in Oracle, and something like them in most other DBMSs

    1) where sales_rep like 'BS%'

    2) where substr(sales_rep,1,2) = 'BS'

提交回复
热议问题