Thanks Peter, I've just found that on the "new" sql build box. I usually use the original sql dialogue, otherwise I find I'm putting tables/column names in the wrong place. But very handy to know about, cheers!
Original Message:
Sent: 07-22-2023 05:10
From: Peter Møller
Subject: Thematic bins / sql "count" within ranges for >16 bins
That is a very useful "hack".
It basically creates a Cross Join where each record in the first table is joined with all records in the second table.
With MapInfo Pro v2019.1 and later, you can do this by adding the "Cross
Join
" keyword after the tables names you are joining - without adding the dummy columns.
There are a few operators that aren't yet supported in a Cross Join for example Between
.
------------------------------
Peter Horsbøll Møller
Principal Presales Consultant | Distinguished Engineer
Precisely | Trust in Data
Original Message:
Sent: 07-21-2023 06:12
From: Uffe Kousgaard
Subject: Thematic bins / sql "count" within ranges for >16 bins
I all fairness: Someone else than me came up with this solution. Many years ago.
------------------------------
Uffe Kousgaard
ROUTEWARE
Roskilde
Original Message:
Sent: 07-21-2023 05:53
From: Caroline Hilton
Subject: Thematic bins / sql "count" within ranges for >16 bins
Uffe thanks a million, that worked perfectly (albeit slowly).
I am intrigued by the dummy field. You would think that a whole column of zeros would send it into a spin.
You are a MapInfo Jedi Master!
------------------------------
Caroline Hilton
Pelican GeoGraphics Ltd (VAR)
Petersfield
Original Message:
Sent: 07-21-2023 02:52
From: Uffe Kousgaard
Subject: Thematic bins / sql "count" within ranges for >16 bins
You need a dummy field for joining, it can be just 0's in both tables.
select ranges.MinValue, ranges.MaxValue, Count(*)
from ranges, InputValues
where ranges.dummy=InputValues.dummy and ranges.MinValue<=InputValues.Value and ranges.MaxValue>=InputValues.Value
group by ranges.MinValue
order by ranges.MinValue
------------------------------
Uffe Kousgaard
ROUTEWARE
Roskilde
Original Message:
Sent: 07-20-2023 07:18
From: Caroline Hilton
Subject: Thematic bins / sql "count" within ranges for >16 bins
Hi
I have a table of points (50k of them), each with an ID number. Many of the ID numbers are repeated, as they're on different sampling lines.
I need to count the number of points which fall between certain ranges.
This is simple to do in "custom ranged thematics", giving me a nice list of point counts, but only for up to 16 bin ranges. I need about 500 bin ranges (which I have in a table: MinID; MaxID).
I don't need the colours, just the count.
I tried to do this in sql and can't work out how to "join" 2 tables - the one with the bin ranges (minID/maxID columns) and the one with the points.
It seems like it should be simple. Something like "where [point_table]pointID>[range_table]minID_value AND [point_table]pointID<=[range_table]maxID_value"
But MapInfo sql doesn't like this as there's no "join" specified.
Thematics does it so quickly, so I'm sure MapInfo is capable, but I don't know how.
Any ideas? If you can even follow what I'm trying to do?
Sample tables below
PointID
3
4
23
456
4
24
25
300
8
etc
MinID MaxID Count
1 12 ?
13 24 ?
25 36
etc
Thanks muchly in advance
------------------------------
Caroline Hilton
Pelican GeoGraphics Ltd (VAR)
Petersfield
------------------------------