Sorting SQL by first two characters of fields

后端 未结 5 443
一生所求
一生所求 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:42

    SELECT * FROM SalesRep
    WHERE SUBSTRING(SalesRepID, 1, 2) = 'BS'
    

    You didn't say what database you were using, this works in MS SQL Server.

提交回复
热议问题