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.

Calculating maximum occurance of values in all records.

Featured Replies

Hi all,

 

Scenario: I have Product and Customer table. I have some records in Product table, having  fields, Product_name, Product_Category, Product_customer.  

And also i have some records in Customer table.

 

e.g, Product table having 5 products. I have 3 transport as Product_category, 2 location as Product_category. John, as value in Product_customer field, in all 5 records. 

 

 

Now , i want to calculate the maximum occurrence of Product_Category of a each customer in Customer table.

 

Output should be Transport.

 

Please see screenshot as reference.

post-104036-0-86787900-1369125443_thumb.

Solved by rivet

Go to solution

1. When you say maximum occurrence, do mean you would like a count for each category?

2. FMP11 or FMP12?

  • Author

It is  fmp12.

 

Suppose there is a customer, John, which has 3 transport and 2 Location as Product category. Since , transport is maximum, i want to to calculate transport / the maximim occurrence of values for a customer in Product_category.

  • Solution

If I understand correctly.

 

1. I would count each category for that client, sort descending using the ExecuteSql function,

2. then take the first line returned with GetValue.

 

 

ExecuteSQL ( "

SELECT

p.category, count ( p.category) AS total

FROM

product p

WHERE

p.id_customer = ? 

GROUP BY

p.category

ORDER BY total DESC

 

 

" ; " " ; "¶" ; customer::id )

 

This will return a sorted array with the highest count at the top of the list, which you can grab with GetValue function.

  • Author

 

Thanks a lot rivet. you solved it.

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.