你是什么数据库?可以用动态sql语句或者存储过程构造一个数据集出来

解决方案 »

  1.   

    1.关于动态建立数据集的例了:
    --建表
    create table ta(elno varchar(1),elrmk varchar(100))
    insert into ta
    select  'A','C1'
    union all select 'A','C2,C3'
    union all select 'B','C1'
    union all select 'A',' R1'
    union all select 'B','D1,D2,D3'
    union all select 'A','D4'
    union all select 'C','C1,C2'
    select * from ta--建臨時表
    create table temtab (id int identity(1,1),elno varchar(1),elrmk varchar(1000))
    insert into temtab(elno) select distinct elno from ta
    select * from temtabdeclare @s varchar(1000)
    declare @maxid int,@intI int
    select @maxid=max(id) from temtab
    set @intI=1
    while @intI<=@maxid
    begin
    set @s=''
    select @s=@s+elrmk+',' from ta  where elno in (select elno from temtab where id=@intI)
    update temtab set elrmk=@s where id=@intI
    set @intI=@intI+1
    end
    --刪除表
    drop table ta
    drop table temtab--測試結果
    select elno,elrmk from temtabelno      elrmk
    =======================================
    A C1,C2,C3, R1,D4,
    B C1,D1,D2,D3,
    C C1,C2,
      

  2.   

    搞错了,应该是这个--测试--测试数据
    create table tt(sid varchar(10),gain int)
    insert tt select 'D001',1000
    union all select 'D001',-400
    union all select 'D002',200
    union all select 'D002',-400
    union all select 'D003',400
    union all select 'D003',0
    go--查询
    select sid,gain,gid=0 into #t from tt order by sid
    declare @sid varchar(10),@i varchar(10),@s varchar(8000)
    update #t set @i=case sid when @sid then @i+1 else 1 end
    ,gid=@i,@sid=sidselect @s='',@i=max(gid) from #t
    while @i>0
    select @s=',[gain'+@i+']=sum(case gid when '+@i+' then gain else 0 end)'+@s
    ,@i=@i-1
    exec('select sid'+@s+',[sum]=sum(gain) 
    from #t group by sid')
    drop table #t
    go--删除测试
    drop table tt/*--测试结果sid        gain1       gain2       sum         
    ---------- ----------- ----------- ----------- 
    D001       1000        -400        600
    D002       200         -400        -200
    D003       400         0           400
    --*/
      

  3.   

    在运行的时候进行判断,如果页宽不够的话,就动态再生成一个.var
      page:TFrPage;
    begin
      frReport1.Pages.Add;
      page:=frReport1.Pages[frReport1.Pages.count-1];
      page.ChangePaper(ASize,AWidth,AHeight,ABin,Aor);
      ...
    end;
      

  4.   

    报表格式我用图已经画出来,见下图
    http://freeking.blogdriver.com/freeking/inc/report.jpg我的QQ:6997072to liufuyahong
    加我QQ好吗?
      

  5.   

    多用几个查询吧,用SQL语句实现比较方便。
      

  6.   

    你的真诚今我感动,
    请教谈不上,
    交流却是非常好的,
    很可惜,我只有网易泡泡的号码,
    名为Yahongq111。
    还是多上CSDN,多研究原码,
    虽然 Delphi版已大不如前。http://freeking.blogdriver.com/freeking/inc/report.jpg
      

  7.   

    我的泡泡是[email protected]
    我加你了,可是不能给你发信息!