Pitney Bowes MapInfo Professional User Manual

Page 241

Advertising
background image

Expanding the text controls is no guarantee that the resulting query can be handled by MapInfo
Professional. You can still receive the Query too complex error when adding larger queries.

Note:

Example 1 - Computing Population Density Using Area

In this example, we will use the world map to create a table of all the countries that have a population
density of over 500 people per square mile.

The following formula computes population density:

• POPULATION / AREA

While the WORLD table has a population column (pop_1994), it does not include a column for country
area. However, since the WORLD table has graphic objects associated with the records, MapInfo
Professional can compute the total area for each country.

Open the WORLD.TAB table, and maximize its display by clicking the window's maximize button. On
the Query menu, click SQL Select to display the SQL Select dialog box.

To complete the SQL Select dialog box:

1. In the From Tables box, choose WORLD from the Tables drop-down list.

You can specify more than one table in an SQL statement. This example uses only one table, WORLD.

You should fill in the From Tables box before you fill in the Select Columns box. MapInfo Professional
uses the tables in the From Tables box to generate the list of columns in the Columns drop-down
list.

2. Place your cursor in the Select Columns box and delete the asterisk (*). In this example, we will

specify a list of columns to be included in the resulting query table, instead of including all columns.

An asterisk (*) in the Select Columns box means by default that all columns would be queried.

Note:

Remember, the query table is the temporary table that MapInfo Professional creates to store the
results of the query.

3. Select Country from the Columns drop-down list.

4. Select pop_1994 from the Columns drop-down list.

Now, we need to compute population density. Remember, population density is computed by dividing
population by area. There is no Area column in the table. However, there is a function, Area, which
will compute the area of any mappable object. Since the WORLD table is mappable, MapInfo
Professional can compute the area of each country and, therefore, the population density of each
country.

5. Select the division sign (/) from the Operators list.

6. Select Area from the Functions popup.

This creates a derived column. A derived column is a column that contains the results of calculations
performed on another column or columns. When MapInfo Professional creates the query table, it will
include two columns: the Country column and the pop_1994/Area(obj, "sq mi") column, which is
our population density column. MapInfo Professional includes a units statement with all geographic
functions. If you wanted MapInfo Professional to return the area in square kilometers, you would
change "sq mi" to "sq km."

Now, we need to build an expression that selects only those countries whose population density is
over 500 people per square mile.

7. Tab to the Where Condition box and select pop_1994 from the Columns drop-down list.

8. Select the division sign (/) from the Operators drop-down list.

9. Select Area from the Functions pop up.

10. Select the greater than sign (>) from the Operators drop-down list.

11. Type the number 500.

241

MapInfo Professional User Guide

Chapter 9: Selecting and Querying Data

Advertising