删除“分组依据”运行时来自 QueryBuildDataSource 的语句

发布于 2024-12-15 11:04:25 字数 90 浏览 0 评论 0原文

我需要从 QueybuildDataSource 对象中删除 group by 语句。 有什么方法可以做到这一点吗? (与 addGroupByField 相反)。

I need to remove a group by statement from a QueybuildDataSource object.
Is there any method to do this? (The opposite of addGroupByField).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

永不分离 2024-12-22 11:04:26

@Artem,我认为你无法从 QBDS 级别做到这一点。我认为你需要从 query().clearGroupBy(); 执行此操作

@ian_scho,信誉度低于 100 的用户在发布后 4-8 小时内无法回答自己的问题......这可能就是他没有发布答案的原因。

@Artem, I don't think you can do it from the QBDS level. I think you need to do it from query().clearGroupBy();

@ian_scho, users under 100 reputation can't answer their own questions for 4-8 hours after posting...that's probably why he didn't post as an answer.

紫瑟鸿黎 2024-12-22 11:04:26

您尝试过吗?...

QueryBuildDataSource qbds = ????;
QueryBuildFieldList qbdsFL;
;
qbdsFL = qbds.fields();
qbdsFL.clearFieldList();

然后您可以添加要以编程方式分组的字段。例如,模仿 Select Distinct 子句

Have you tried?...

QueryBuildDataSource qbds = ????;
QueryBuildFieldList qbdsFL;
;
qbdsFL = qbds.fields();
qbdsFL.clearFieldList();

You can then add fields to be grouped programmatically. Mimmicking a Select Distinct clause for example.

等风也等你 2024-12-22 11:04:26

不幸的是,x++ 没有任何方法从 group by 中删除一个字段,但通过一些技巧我们可以做到这一点。我编写了一种用于删除分组依据字段的方法:

public void removeGroupByField(FieldID _fieldId, TableId _tableId, Query _query)
    {
        int i = 1;
        QueryGroupByField       qgbf;
        QueryBuildDataSource    qbdsOld, qbdsNew;
        Query                   newQuery;

        qbdsOld             = _query.dataSourceTable(_tableId);

        newQuery            = new Query(_query);    
        qbdsNew             = newQuery.dataSourceTable(_tableId);

        newQuery.clearGroupBy();

        for(i = 1 ; i<= _query.groupByFieldCount(); i++)
        {
            qgbf    = _query.groupByField(i, qbdsOld);
            
            if(qgbf.fieldID() != _fieldId)
            {
                qbdsNew.addGroupByField(qgbf.fieldID());
            }
        }

        _query  = newQuery;
    }

为了获得更好的性能,您可以更改此方法以输入您想要从分组依据中删除的字段 Id 的容器。

Unfortunately, x++ does not have any method to remove one field from group by but by some tricks we can do that. I have written a method for removing group by field:

public void removeGroupByField(FieldID _fieldId, TableId _tableId, Query _query)
    {
        int i = 1;
        QueryGroupByField       qgbf;
        QueryBuildDataSource    qbdsOld, qbdsNew;
        Query                   newQuery;

        qbdsOld             = _query.dataSourceTable(_tableId);

        newQuery            = new Query(_query);    
        qbdsNew             = newQuery.dataSourceTable(_tableId);

        newQuery.clearGroupBy();

        for(i = 1 ; i<= _query.groupByFieldCount(); i++)
        {
            qgbf    = _query.groupByField(i, qbdsOld);
            
            if(qgbf.fieldID() != _fieldId)
            {
                qbdsNew.addGroupByField(qgbf.fieldID());
            }
        }

        _query  = newQuery;
    }

And for better performance u can change this method to input container of field Id which u want to remove from group by.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文