progress 中的break by 以及first-of

来源:互联网 发布:ubuntu net tools 编辑:程序博客网 时间:2024/05/20 05:56

以下操作只针对于数据库中含有相应的表和字段,若要自己练习,可根据情况修改

1.在不含break by 情况下查找数据库中数据

for each xmptt_mstr :

 display  xmptt_pdl xmptt_tt  .
end.

|生产线                Take Time|
|------------------ ------------|
|pl00                        5.0|
|pl01                        4.0|
|pl02                       45.0|
|pl17                        5.0|
|pl19                        5.0|
|pl23                        5.0|
|pl33                        4.0|

|                               |

--------------------------------------------------------------------------------
2.在含有break by情况下查找数据库
for each xmptt_mstr break by xmptt_tt : /*progress中默认是升序*/
 display  xmptt_pdl xmptt_tt  .
end.

+-------------------------------+
|生产线                Take Time|
|------------------ ------------|
|pl01                        4.0|
|pl33                        4.0|
|pl00                        5.0|
|pl17                        5.0|
|pl19                        5.0|
|pl23                        5.0|
|pl02                       45.0|
|                               |

--------------------------------------------------------------------------------
3.含有break by 且降序排列,每一个by 就是一次排序
for each xmptt_mstr break by xmptt_tt  by  xmptt_pdl desc:  /*desc  降序,当不写desc时,系统默认为升序*/
 display  xmptt_pdl xmptt_tt  .
 end.

+-------------------------------+
|生产线                Take Time|
|------------------ ------------|
|pl33                        4.0|
|pl01                        4.0|
|pl23                        5.0|
|pl19                        5.0|
|pl17                        5.0|
|pl00                        5.0|
|pl02                       45.0|
|                               |

--------------------------------------------------------------------------------
4.含有break by 和 first-of 以及 降序排列,并计算以xmptt_tt排列的相同数据求和
     define variable a as int .
     define variable b as int .
     b = 0 .
        for each xmptt_mstr break by xmptt_tt  by  xmptt_pdl desc:
               if first-of(xmptt_tt) then do :
                    a = 0 .
                    b = b + 1 .
                    message    b.
                end.
                   a  = a +  xmptt_tt .
                display a  xmptt_pdl  xmptt_tt .
        end.

+------------------------------------------+
|         a 生产线                Take Time|
|---------- ------------------ ------------|
|         4 pl33                        4.0|
|         8 pl01                        4.0|
|         5 pl23                        5.0|
|        10 pl19                        5.0|
|        15 pl17                        5.0|
|        20 pl00                        5.0|
|        45 pl02                       45.0|
|                                          |

--------------------------------------------------------------------------------
5.含有break by 和 first-of 以及 降序排列,并计算以xmptt_pdl排列的相同数据求和
   
     define variable a as int .
         
     define variable b as int .
     b = 0 .

    for each xmptt_mstr break by xmptt_tt  by  xmptt_pdl desc:
        if first-of(xmptt_pdl) then do :
        a = 0 .
        b = b + 1 .
        message    b.
        end.
        a  = a +  xmptt_tt .
        display a  xmptt_pdl  xmptt_tt .
     end.


|         a 生产线                Take Time|
|---------- ------------------ ------------|
|         4 pl33                        4.0|
|         4 pl01                        4.0|
|         5 pl23                        5.0|
|         5 pl19                        5.0|
|         5 pl17                        5.0|
|         5 pl00                        5.0|
|        45 pl02                       45.0|
|                                          |