Get data from 2 contents

  1.  
    1. Hi,

      I'm new in MQL. I try to get list of countries sorted by population. I came from the Vietnamese restaurant query which is working:

      [
        {
        "/business/business_location/address" : {
        "citytown" : null,
        "state_province_region" : null
        },
        "cuisine" : "Vietnamese",
        "name" : null,
        "type" : "/dining/restaurant"
        }
      ]

      Modified query gives me surprisingly an error (not mentioned the sorting issue):

      [
        {
        "/location/statistical_region" : {
        "population" : null
        },
        "name" : null,
        "sort" : "name",
        "type" : "/location/country"
        }
      ]
       

      Any help is appreciated

      Robert 

      1. The problem with your query is that you are looking for a country that has a statistical region that has a population. That is not what you want. You want a country which, when considered as a statistical region, has a population. Or more succinctly, you want a country with a population.

        When treating a topic with more than one type, you often need to use the fully-qualified property names. You were on the right track, but rather than using a subordinate object, you just wanted a longer string. Consider:

        [{"name":null,"type":"/location/country", /location/statistical_region/population":[{"number":null,"year":null}]}]

        That will get you the populations. Note also that we have to delve into the population, since it actually has a number and a year, not just a number.

        You can sort by any property present in the response, and use periods to nest. To sort by the population number, you’ll want to sort the populations for a specific country first, then sort the countries by their highest populations:

        [{"name":null,"type":"/location/country", /location/statistical_region/population":[{"number":null,"year":null,"sort":"-number"}],"sort":"-/location/statistical_region/population.number"}]

        That will sort the way you want. You will find that former countries show up in that list; you may want to constrain the years for the population counts.

    Discussion is posted in:

    Think this discussion also relates to something else? Cross-post it by adding a new discussion area:

Search Discussions