1、input '请输入部门编码:' to bm
   count to rs for left(编号,2)=bm
   ? '人数:“ rs

解决方案 »

  1.   

    2、
      s=0
      for i=1 to 99 step 2
        s=s+i
      endfor
      ? "1+3+5+7+……+99=" s
      

  2.   

    哎呀,乱了,重写:
    1、accept '请输入部门编码:' to bm
       count to rs for left(编号,2)=bm
       ? '人数:'+str(rs)
    2、s=0
       for i=1 to 99 step 2
          s=s+i
       endfor
       ? "1+3+5+7+……+99="+str(s)
    3、count to a1 for 产量<10
       count to a3 for 产量>20
       ? '大型厂:'+str(a3)
       ? '中型厂:'+str(10-a1-a3)
       ? '小型厂:'+str(a1)
      

  3.   

    CREATE TABLE aa (cname c(6) PRIMARY KEY, qty n(5))
    insert into aa ('1',10)
    insert into aa ('2',8)
    insert into aa ('3',12)
    insert into aa ('4',20)
    insert into aa ('5',4)
    insert into aa ('6',16)
    insert into aa ('7',18)
    insert into aa ('8',30)
    insert into aa ('9',2)
    insert into aa ('10',37)
    count to rs1 for qty <10
    count to rs2 for qty >=10 and qty <=20
    count to rs3 for qty >20
      

  4.   

    to liuri(璇玑) :我不懂VFP,感觉这个“?”是输出的意思是吗?我确定一下是不是乱码,呵呵,别笑话我
      

  5.   

    呵呵,我明白了,类似于c++的cout是吗。多谢多谢。
      

  6.   

    基本同意 liuri(璇玑) 的答案。不过略作修改:1、自动计算所有部门的人数:
       set delete on   && 删除标志起作用
       select gzgl
       go top
       do whil ! eof()
          bm=left(编号,2)
          count for left(编号,2)==bm to rs_&bm
          ? bm+'部门的人数为:'+str(rs_&bm)   && 输出结果
          delete all for left(编号,2)==bm
          go top
       enddo
       recall all  && 将所有记录去掉删除标志
      

  7.   

    suyman(CBA) ,我想如果楼主真是要实现你这种功能的话,应该用一个临时表的效果要好一些:
    SELECT count(*) as 人数,LEFT(编号,2) as bh FROM gzgl GROUP BY bh
      

  8.   

    suyman(CBA) ,我想如果楼主真是要实现你这种功能的话,应该用一个临时表的效果要好一些:
    SELECT count(*) as 人数,LEFT(编号,2) as bh FROM gzgl GROUP BY bh
      

  9.   

    liuri(璇玑) :Very good, quite right! (我对SQL语法知之不深,不知道该怎么写,谢谢你写出来了)