select kemu from table1create table2 depandent on the select result
實現方法: 如果課程不固定,則需建兩個表,一個表存儲課程名,另一個表存儲成績. 1.Select * From 課程名,將課程名寫到列表視控件的標題欄上.並建一個數組存儲課程名 2.Select 學號,姓名,課程,成績 From 成績表 Order By 學號 設一變量 var學號="" 開始循環讀記錄 if (當前記錄學號!=var學號) { var學號=當前記錄學號; 增加新Item,學號,姓名, 與課程數組比對,確定在第幾個SubItem上顯示成績 } else { 與課程數組比對,確定在第幾個SubItem上顯示成績 }
Which Database? SQL Server or Oracle or DB2?
SQL SERVER 7 有劳bob_yan(小保) 兄。
你好,我用存储过程给你实现。但是这个存储过程功能比较简单,只能处理课程是固定数目的情况。想要更简单的实现你的要求,建议你用PB的一些方法去做。你现看看下面的方法能不能实现你的要求。 declare @xuehao1 char(3) declare @xuehao2 char(3) declare @xinming char(20) declare @kechen char(10) declare @chenji int declare @totalcore intselect @xuehao1='' select @xuehao2='' select @totalcore = 0 select @kechen='' select @chenji=0create table #tmp xuehao char(3),xinming char(20) null,wangluo int null, yinyu int null,gaoshu int null, zongfen int null declare tmpcur cursor for select xuehao,xinming,kechen,chenji from table1 order by xuehao,kechen for read only open tmpcur fetch tmpcur into @xuehao1,@xinming,@kechen,@chenji while (@@fetch_status=0) begin if (@xuehao1<>@xuehao2) begin insert into #tmp(xuehao,xinming) values (@xuehao1,@xinming) select @xuehao2=@xuehao1 end if (@kechen='wangluo') update #tmp set wangluo=@chenji where xuehao = @xuehao1 if (@kechen='yinyu') update #tmp set yinyu=@chenji where xuehao = @xuehao1 if (@kechen='gaoshu') update #tmp set gaoshu=@chenji where xuehao = @xuehao1 fetch tmpcur into @xuehao,@xinming,@kechen,@chenji end close tmpcur deallocate tmpcur select *,wangluo+yinyu+gaoshu zongfen from #tmp
如果課程不固定,則需建兩個表,一個表存儲課程名,另一個表存儲成績.
1.Select * From 課程名,將課程名寫到列表視控件的標題欄上.並建一個數組存儲課程名
2.Select 學號,姓名,課程,成績 From 成績表 Order By 學號
設一變量 var學號=""
開始循環讀記錄
if (當前記錄學號!=var學號)
{
var學號=當前記錄學號;
增加新Item,學號,姓名,
與課程數組比對,確定在第幾個SubItem上顯示成績
}
else
{
與課程數組比對,確定在第幾個SubItem上顯示成績
}
declare @xuehao1 char(3)
declare @xuehao2 char(3)
declare @xinming char(20)
declare @kechen char(10)
declare @chenji int
declare @totalcore intselect @xuehao1=''
select @xuehao2=''
select @totalcore = 0
select @kechen=''
select @chenji=0create table #tmp xuehao char(3),xinming char(20) null,wangluo int null, yinyu int null,gaoshu int null, zongfen int null
declare tmpcur cursor for
select xuehao,xinming,kechen,chenji from table1 order by xuehao,kechen
for read only
open tmpcur
fetch tmpcur into @xuehao1,@xinming,@kechen,@chenji
while (@@fetch_status=0)
begin
if (@xuehao1<>@xuehao2)
begin
insert into #tmp(xuehao,xinming) values (@xuehao1,@xinming)
select @xuehao2=@xuehao1
end
if (@kechen='wangluo')
update #tmp set wangluo=@chenji where xuehao = @xuehao1
if (@kechen='yinyu')
update #tmp set yinyu=@chenji where xuehao = @xuehao1
if (@kechen='gaoshu')
update #tmp set gaoshu=@chenji where xuehao = @xuehao1
fetch tmpcur into @xuehao,@xinming,@kechen,@chenji
end
close tmpcur
deallocate tmpcur
select *,wangluo+yinyu+gaoshu zongfen from #tmp
PB里的确有一种CROSSTAB风格的数据窗口可以很容易的做出该报表, 但是CROSSTAB有个BUG 就是在数据量大时会导致电脑死机。(只能重新启动)
VC的确是一种很强的工具。 PB 本身就是 VC 写出来的。 既然PB 都做出来了。 VC 因更不在话下啊。 bob_yan(小保) 兄 能不能找找您认识的VC高手们说说。
其实PB做报表比VC好很多,有会,应该可以更方便地找到方法。