11 Replies Latest reply on Aug 26, 2013 10:32 AM by beverly

    SQL nested query

    JavierDura

      Hi, everyone.

       

       

      I have a database with only one table called People.

      It has 3 fields:

       

      id (autoenter)

      name

      countryOfOrigin

       

       

      It has 6 records:

      Peter... UK

      John.... UK

      Michael.. USA

      Sara...... Spain

      Mat....... Spain

      Joe........ Spain

       

       

      I use the following query...

       

       

      ExecuteSQL ( "

      SELECT DISTINCT

      "countryOfOrigin"

      FROM

      People

      "

      ; "" ; "")

       

       

       

       

      to get a list of countries like this:

       

      UK

      USA

      Spain

       

       

      How can I improve my query to get the number of records of each country? In other words, I need to get this:

       

       

      Spain.... 3

      UK........ 2

      USA....... 1

       

       

      As I said, my file has only one table and no value lists.

       

       

      Thanks!