0

I saw a lot of this kind of SQL statements. The are a WHERE condition with < as on a string column. But how is this possible? A string ist not a number.

SELECT 
       [SalesTerritoryCountry]
      ,[SalesTerritoryGroup]
  FROM [AdventureWorksDW2019].[dbo].[DimSalesTerritory]
WHERE [SalesTerritoryCountry] < [SalesTerritoryGroup]
Mikkey200
  • 25
  • 3
  • 4
    It's called lexicographical ordering. Strings are compared character-wise, from the first character. – gaborsch Sep 21 '22 at 19:21
  • 1
    This ^. Read more about it here: [What is lexicographical order?](https://stackoverflow.com/questions/45950646/what-is-lexicographical-order) – griv Sep 21 '22 at 19:24

0 Answers0