Myth of Cambodia Geography Identification Code

How many of you are familiar with Cambodia Geography Identification code. Do you know the myth behind it code assignment? Well, it’s all started like this:

  • There are 4 levels of administration
    • Province
      • District
        • Commune
          • Village
  • Each level add up 2 digits begin with Province 2 digits
  • Identification code are stored in numberic form (Integer)

That mean valid village code length bewteen 7 and 8 for example code 24020406 would identified as:

  • Village Name = Ou Ressey Loeu (24020406)
  • In Commune  = Ou Andoung (240204)
  • In District = Sala Krau (2402)
  • In Province = Pailin (24)

Now suppose these Geography represent in 4 separate tables (SQL Server for ghost shack!) 

geography

By knowing a village code (eg:  24020406) I want to extract province code and I want the quickest way possible any thought? Oh ! there will be a reward for best answer.

One thought on “Myth of Cambodia Geography Identification Code

  1. // In C# you can do:
    int villageCode = 24020406 ;
    int provinceCode = villageCode / Math.Pow(10,6); // 24
    
    // In Ms. Excel:
    Cell A1 = 24020406 
    Cell A2 = "=INT(A1/10^6)
    
    // In Ms. Access:
    SELECT (vil.Id\10^6) as ProvinceId 
      FROM GISVillage vil WHERE vil.Id = 24020406 
    
    // SQL Server
    SELECT (vil.Id/POWER(10,6)) as ProvinceId 
      FROM GISVillage vil WHERE vil.Id = 24020406 
    
    // ... what else ?
    

Leave a comment