- Local time
- Today, 10:40
- Joined
- Oct 29, 2018
- Messages
- 22,770
Hi. You're welcome. Yes, it would work just fine using only one query, as Minty posted earlier. However, when I realized you're trying to combine all the Regions from the same table, I thought that is probably why it's running slow for you (you said 3 minutes earlier). The reason for it is because Allen Browne's function is being executed for each row of the query, which means if you had 100 records but only 10 distinct records, the function is still called 100x100 times. The immediate result would be 100 records with a bunch of duplicates, which the DISTINCT keyword then pares down to only 10. Whereas, using a separate query to perform the paring down to 10 distinct records before running Allen Browne's function, then we only get it run 10x100. Normally, you would have a separate table for Regions, which contains unique records, and then use it against your table when using Allen Browne's function. Hope it makes sense...DBGuy, that works. Thank you for the solution!
However it seems odd that you would have to make a select distinct query and then pull the data from that. I can't see a reason why you can't just pull from the table directly. I guess it doesn't matter as long as it works, just irritates me I can't find a simpler solution.
Thank you!!