Hi,

I think you have found one of the things that the SQL syntax doesn't allow. 
There is a few combinations that MapInfo doesn't allow. To get around them you 
can most do your SQL in 2 steps in stead of just one:

1.
Select Sum(population) "SUM_POP", Sum(Area) "SUM_AREA"
        From ...
        Into SQL_PART1

2.
Select SUM_POP/SUM_AREA "Density"
        From SQL_PART1
        ...

HTH,
Peter Horsb�ll M�ller
GIS Developer
Geographical Information & IT
 
COWI A/S
Odensevej 95
DK-5260 Odense S.
Denmark
 
Tel     +45 6311 4900
Direct  +45 6311 4908
Mob     +45 5156 1045
Fax     +45 6311 4949
E-mail  [EMAIL PROTECTED]
http://www.cowi.dk/gis


-----Original Message-----
From: Lawson Key [mailto:[EMAIL PROTECTED] 
Sent: Friday, December 10, 2004 5:54 PM
To: [EMAIL PROTECTED]
Subject: MI-L Defining a custom field in an SQL Select Query - Making 
expressions with Functions


Hi list,

 

I'm doing some population density calculations using the SQL Select tool.  I 
have population data and area data for several hundred regions in a table.  In 
order to get the aggregate density for the total area, I'm summing these two 
fields in a query and manually dividing total population by total area.  My 
issue is that MapInfo allows me to define two separate columns using the sum(*) 
function, but when I try to define a single density field, which looks 
something like this:

 

Sum(population)/Sum(Area) "Density"

 

It doesn't work.  "Found[/] while searching for [A string constant]" is the 
error I get.  Interestingly, the following custom fields do work:

 

Population/Area - returns the density of each region in the table

 

Sum(Population/Area) - returns the sum of all regions' density, which is 
meaningless.

 

I don't want a MapBasic solution, I would just like someone to confirm that 
what I'm trying to do is not allowed, or let me know if there is a way.  This 
problem isn't keeping me from doing my work, I'm just surprised that this 
functionality isn't available and want to test my findings with the list.  
Using MapInfo Pro 6.5

 

Lawson Key

CenturyTel


---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 14497

Reply via email to