beautypg.com

Calculating the distance to a fixed point – Pitney Bowes MapInfo Professional User Manual

Page 257

background image

Order by Columns: 2 desc

into Table Named: Selection

Substitute the name of your data column for ID_Num and the name of your table for EMPLOYEE. The
number 1 in the Group By Columns box will group the row by ID_Num (the first column). The 2 Desc
in the Order by Columns box will arrange the records in descending order based on the values in
the count(*) field (the second column).

This SQL Select statement returns a query table with two columns. The first column contains every
identification number possessed by at least one employee. The second column contains the number
of employees that have that identification number. The rows are sorted by the number of employees
that have each id number (for example, the count).

2. On the Query menu, click SQL Select and fill in the dialog box.

Also, change EMPLOYEE to the name of your table and ID_Num to the name of your data column.

In the example, the SQL statement returns a query table containing all of the rows from EMPLOYEE
with duplicated data column values. The where condition selects all rows from EMPLOYEE that have
an identification number that is the same as one of the ID numbers in the Count_By_ID query table. This
sub-select finds all identification numbers that occur more than once.

Calculating the Distance to a Fixed Point

In MapInfo Professional it is possible to calculate the distance from one point to another. This example
shows how to calculate the distance from a fixed point to every point in a geocoded table and store the
result in another table.

1. Determine the location of the fixed point. To find the position of a symbol on the map, double-click

the symbol with the Select tool. In this example, the X value is -101.697209 and the Y value is
35.550036.

2. On the Query menu, click SQL Select and fill in the SQL Select dialog box, substituting your X and

Y values for the values mentioned above

As in the previous SQL query, replace EMPLOYEE with the name of your table, and LName and FName
with the name of the relevant column from your table.

Select Columns: LName, FName, Distance(-101.679209, 35.550036,

CentroidX(obj), CentroidY(obj), "mi") "Dist"

from Tables: EMPLOYEE

into Table Named: CUSTDIST

3. Click OK. The resulting query table contains last names and first names plus a new column called

DISTANCE which records the distance between the fixed location (-101.697209, 36.550036) and
the point associated with each row of the table.

4. To save the results in a permanent table, on the File menu, click Save Copy As, and save the

CUSTDIST table.

5. For instructions on entering SQL queries using the Expert button, see the Help System.

257

MapInfo Professional User Guide

Chapter 9: Selecting and Querying Data