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.

Equivalent of SQL Group by and Sum

Featured Replies

Hi,

I'm having a problem conceptualizing an SQL query in FM.

How would you do the equivalent of a SQL Group BY and SUM in FM?

Let say I have a single table:

FILES (pkFileID, fkDayID, FileCode, WorkedTime)

pkFileID --> Primary key

fkDayID --> Foreign key

FileCode --> A Code such as "GE-TR-123"

WorkedTime --> A number which represents the work time on a file.

In SQL would do:

SELECT Files.FileCode, SUM (Files.WorkedTime) as TotalWorkedTime

FROM Files

GROUP BY Files.FileCode

This would give me a list with the amount of work time for each FILE.

How can I get the equivalent in FM?

Thank you

Look into subsummary reports. You can group by fields. Create a new columnar list/report layout and follow the wizard.

  • Author

I tried all the possible ways with the wizard and I am not able to get the wanted solution. When I do grouping, how do a I get the sum?

Here is what I get:

sshot42vc6.jpg

As you can see, the total time per file is not good since it is a repetition of the summary field totalTime. And the values are not grouped.

Is it possible to create a SQL Group-by Sum? Like I posted in the first post.

Perhaps if you'd used the wizzard, you could have seen which data you needed to allocate to where and why?

But as it is should your summary field should be moved to a subsummary part, say - next to you filecode field instead of being in the body as it is on your image. Perhaps what you really want is to get rid of the body-part ...then delete it after moveing the summaryfield to it's correct location.

--sd

  • Author

Thanks to both of you! It worked in the subsummary field, although I still prefer SQL method. The only thing is that I had to hide the body, since it was not useful...

sshot43ko4.jpg

Edited by Guest

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.