前往Shuct.Net首页

Shudepb PB反编译专家长时间以来,为业内同类软件事实上的唯一选择.细节,彰显专业.态度,决定品质.

关于PowerBuilder的搜索

聚集之聚集:在数据窗口中计算分组总计之和,PowerBuilder,数据库 在线留言 | Alexa查询 | 在线工具 | 技术论坛 | 会员注册 | 繁文 首页 WEB编程 WEB设计 WEB标准 脚本特效 WEB安全 数据库 开发工具 资源下载 WEB资讯 欢迎访问阿里西西WEB开发技术网站! → ASP编程| PHP编程| JSP编程| ASP.NET| C#.NET| VB.NET| Cgi/Perl| XML/RSS| → WEB设计软件| WEB设计艺术| WEB设计规范| WEB设计欣赏| → HTML| XHTML| CSS样式表| → JavaScript| VBScript| → WEB服务器| WEB黑客攻防| WEB攻防工具| → ACCESS| MSSQL| MySQL| Oracle| PowerBuilder| FoxPro| DB2| → Dreamweaver| FrontPage| Fireworks| FLASH| Ultradev| 精品工具| → 电子教程手册| 语言参考手册| 网站开发文档| 精典源码函数| → 互联网新闻| WEB市场推广| WEB程序员专栏| ACCESS MSSQL MySQL Oracle PowerBuilder FoxPro DB2 首页 / 数据库 / PowerBuilder / [PowerBuilder] 聚集之聚集:在数据窗口中计算分组总计之和 作者:[转载] 文章来源:http://www.alixixi.com/ 更新时间:2005-12-13 DataWindows- Aggregates of Aggregates: Providing Sums of Group Totals in the Summary Band of a DataWindow   SUMMARY: Normally you would not be able to perform aggregates of aggregates (i.e if you have a computed field in the group trailer band of a datwindow you cannot summarize that information in a calculated field located in the datawindow's summary band). This document describes a technique that will allow you to perform this through coding in the RetrieveEnd event of a datawindow. Document ID: 47734 Last Revised: 04/12/99 Topic: DataWindows Document Type: TechNote Product: PowerBuilder Version: 7.0; 6.0; 5.0 Platform: PC Operating System: Windows 3.1, Windows 95, Windows NT Document:   When using computed fields in a datawindow it is not possible to compute aggregates of aggregates, meaning that, if you have a computed field in the group trailer band of a datwindow you cannot summarize that information in a calculated field located in the datawindow's summary band. The reason for this is that the aggregate data is computed at run time and is not stored anywhere which makes it unavailable for another aggregate function to act upon. It is possible to summarize the calculated data in a script and then write the result into an object that has been placed in the summary band of the datawindow for that purpose.   A sample scenario would be a datawindow which retrieves rows from a table containing employee data (first name, last name, department, salary, etc.) and groups those rows by department. A calculated field in the datawindow's group trailer band provides a salary total for the department. A salary total for departments with dept_id=200 or 300 is required in the summary band of the datawindow.   The following script, when placed in the RetrieveEnd event of the datawindow, will find each group break, add the value of the calculated field for that group to a summary variable and then write the grand total to a text object which was placed in the datawindow's summary band for that purpose. To provide a consistent look and feel to the report, make sure that the font for the text object is the same as the other objects in the datawindow. Note that the RetrieveEnd event has a single argument, "rowcount", which is the number of rows that were retrieved. The name of the calculated field in the group trailer band is "sal_tot" and the name of the text object in the summary band is "dept_200_300". long brk_row = 0,cnt decimal{2} g_tot, lsum=0 For cnt = 1 to rowcount brk_row = this.FindGroupChange(brk_row,1) If brk_row <= 0 then Exit IF this.GetItemNumber(brk_row,'dept_id') = 200 or & this.GetItemNumber(brk_row,'dept_id') = 300 THEN g_tot = this.GetItemNumber(brk_row, 'sal_tot') lsum = lsum + g_tot END IF brk_row = brk_row + 1 Next this.object.dept_200_300.text = string(lsum, "$###,###,##0.00")   Note: If you simply wanted to get a total of all the salaries for all departments, you could use a caculated field in the datawindow with the expression: sum(salary for all).   Related faxline documents   44415 Converting a Computed Field to a Computed Column   42042 Determining the Number of Group Level Breaks in a Datawindow (PB 4.0, 5.0) 【发表评论】 【加入收藏】 【打印此文】 【关闭窗口】 上一篇:将数据窗口保存为完整的Excel表格 [2005-12-13] 下一篇:开发和运行环境中的动态连接库 [2005-12-13] 网友评论 相关搜索 关于我们|网站地图|隐私和安全性|联系我们|在线工具|友情链接|粤ICP备05097432号 &copy;2004-2005 Alixixi Development Team.All rights reserved 保留所有权利。 访问本网站表明您同意信息使用条款。