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.

Featured Replies

I successfully implemented a SQL function in my database thanks to Mr. Vodka, I tried to 'recycle' it to evaluate a numeric field but it doesn't work, what am I missing?

GetValue (

ExecuteSQL ( "
              SELECT
              Left(Position + '             ',12),
                  Count ( Position ) AS kount
              FROM HighScores
              GROUP BY Position
              ORDER BY kount DESC
             ";
              "     "; ""; ""
           )

            ; Get ( CalculationRepetitionNumber )
           )
Position is a numeric field, if I replace that field with another text field the function works just fine (it counts the instances and present me a top three).

Left(Position +' ' etc. looks strange to me. I don't believe the syntax is correct. I'm on an iPad and can't test. Perhaps you need & instead of +?

  • Author

The Left(Position etc... works, it tells the function to put some spaces after the result and to take the first 12 characters; infact if I change the field to a non-numeric one it works just fine; anyways I tried to replace the line you mentioned with "Position," and it doesn't work anyways.

SQL has stricter rules for data than FM. Why are you putting spaces in there again?

  • Author

The Left thing and the spaces are to tell SQL to display neatly the two 'columns'; anyways, even if I put simply the field name it does NOT work since 'Position' is a numeric field, do I need a different function to handle numbers and count like in the other instance you helped me solve?

GetValue (

ExecuteSQL ( "
              SELECT
              Position,
                  Count ( Position ) AS kount
              FROM HighScores
              GROUP BY Position
              ORDER BY kount DESC
             ";
              "     "; ""; ""
           )

            ; Get ( CalculationRepetitionNumber )
           )

I'm very much SQL novice, but I downloaded the sample and tinkered...

 

POSITION is a reserved SQL keyword - rename your field. See the ODBC/JDBC docs

 

I really have to thank you for forcing me to learn this one!!

  • Author

'Position' is a sample name, the real field's called 'Level'.

LEVEL is also a reserved keyword in SQL

  • Author

I renamed the 'Level' field into 'Lvlqwerty' and it still returns a "?".

  • Author

I am a bit confused. Maybe I should put it in a script as you did to make it work? Because the result's given in a window and I'd want to get it in a field.

should work just the same.

  • Author

If I use the same formula in a calculation field instead of returning the wanted result it gives me a "?", I believe I am missing something? The thing I fail to understand is that if I use a text field in the SQL formula it works just fine.

P.S. I Included an example of what I would like to achieve.

top3_countSample.zip

You have a couple of things that are off:

 

1) there is a typo in the SQL statement: Count ( Positr )  --> remove the "r"

2) the field is set up to return a numeric value but the calc itself will return a text string --> change the field result to text

 

To guard against 1), where you use hard-coded field names and table names, use get(fieldname) and parse out the part that you need.  That embeds a real reference to the field.

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.