Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

FM 12 ExecuteSQL statement not working...seems simple...

Featured Replies

Can someone help me figure out why this, apparently, simple ExecuteSQL statement doesn't work?

post-105601-0-78849900-1339817768_thumb. The short description is that we are trying to count the occurrence of words. The table has some 4100+ records, each one (the "Text" field) simply a word from a document. I was trying to test if putting a numeric identifier for a word, instead of the text word itself, would be faster. (The text based 'Group By...' takes 25 seconds!!) So I have been trying to test whether different techniques will help (indexing, this numeric field thing, etc). Here's a sample of my data:

ExecuteSQL (

"SELECT Text, GroupNum, Count (GroupNum)

FROM Test

GROUP BY GroupNum"

;"";""

)




While this version does (only removed the "Text" field from the Select):


ExecuteSQL (

"SELECT GroupNum, Count (GroupNum)

FROM Test

GROUP BY GroupNum"

;"";""

)




I have a very simple table structure as I was just doing some SQL testing.  See attached image cap.




availability    96

availability    96

available    97

average    98

awake    99

aware    100

aware    100

away    101

back    102

back    102

bag    103

balance    104

ball    105

barely    106

barometer    107

barrel    108

barrel    108

barrels   109 

So, my SQL is just designed to give me the resulting count of words, in one field ("Results"). So I wanted to make it prettier by including the "Text" word as well as the numeric version.

Thanks,

J

Hi there,

when using an aggregate function (such as COUNT, SUM...), you MUST put all the other columns (ie that are not aggregated) in the GROUP BY.

Therefore, try :

ExecuteSQL(

"SELECT Text, GroupNum, Count (GroupNum)

FROM Test

GROUP BY Text, GroupNum"

;"";""

)

  • Author

Hi there,

when using an aggregate function (such as COUNT, SUM...), you MUST put all the other columns (ie that are not aggregated) in the GROUP BY.

Therefore, try :

ExecuteSQL(

"SELECT Text, GroupNum, Count (GroupNum)

FROM Test

GROUP BY Text, GroupNum"

;"";""

)

Laurent,

Thanks for the tip. It seems like an odd requirement, however. But, it did work...to an extent. Unfortunately, it is now doing TWO Group By operations, and so now takes 38 seconds instead of 19. However, that is still slightly faster than doing the SQL against the Text field directly (about 22 seconds for that one).

Thanks,

J

  • Author

I tried it both ways and didn't see a change in performance. :(

How many records are we talking about? 22 seconds seems awfully long for that. I have a layout with about 100 separate calls that groups and sums, the largest data sets take at most 15 seconds.

  • Author

About 4100 records. Simple structure just to do some of this ExecuteSQL testing: one table (no T.O.s), 7 or so fields...posted a pic of the table back a few messages.

  • 3 weeks later...

"Text" is probably a reserved keyword so I would try to rename the field and try again with the original query.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.