Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

group by in aggregate query

edited February 2008 in General
I can perform the following aggregate query in sql where I group by the
calculated field for Month and Year portion of a date. However, I cannot
figure out how to accomplish this in Data tab / Query Designer. I can
create the calculated fields but cannot figure out how to get the group by
them

select Month(ScheduledDate), Year(ScheduledDate), Count(Numbered) from
WoMaster
group by Month(ScheduledDate), Year(ScheduledDate)
order by Year(ScheduledDate), Month(ScheduledDate)

I named them SMonth and SYear for the alias but they do not show up in the
Group By tab for selection.

Any suggestions?

Thanks,
Bob

Comments

  • edited February 2008
    Hi Bob,

    Grouping by non-aggregate calc fields (as in your example) is currently not
    supported in ReportBuilder due to the fact that not all Databases
    (especially in the past) support this action. We are strongly considering
    adding this capability for the next release as it seems it is becoming more
    widely supported by the latest DB's used by our customers.

    The current alternative is to edit the SQL as text and manually add the
    GroupBy clause yourself.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2008
    When you say the alternative is to edit the SQL as text and manually add the
    GroupBy clause, is this something the user can do in the report builder at
    runtime or do we have to do it from Delphi?

    Thanks,
    Bob

  • edited February 2008
    Hi Bob,

    At runtime if the TppDesigner.DatabaseSettings.AllowEditSQL property is set
    to True, you have the ability to navigate to the SQL tab in the Query
    Designer, right click and edit the SQL code manually.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2008
    After all these years.. I did not know that.

    Thanks,
    Bob

This discussion has been closed.