Between first letter in last name (WHERE clause)

  • Hi All,

    Not sure if this can be done in T-SQL but I was curious if there is a way to filter on a range based on the the first letter in the last name. So basically I want to get everything where the last name between A and M. then N and Z. Something like:

    WHERE P.LAST_NAME BETWEEN LIKE 'A%' AND LIKE 'M%'

    Of course this doesn't work, but just wanted to show what I'm attempting to do.

    Thanks,

    Strick

  • WHERE LEFT(LastName,1) BETWEEN 'A' AND 'M'

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • Try this:

    select * from person.contact where LastName like '[A-N]%'

    Regards

    Piotr

    ...and your only reply is slàinte mhath

  • Great! thanks guys

    Strick

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

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