以下語句在SQL 7.0上通過,為什么在Delphi 5.0的ADO(ADOQuery)上無法執行,請高手指點!!!
*****************************************
declare @a int,@b int  //此處已經不可以了,??
select identity(int) id0,name,score into #temp1 from test1
where score <60 order by name; --不及格select identity(int) id0,name,score into #temp2 from test1
where score >=60 and score <80 order by name; --60~80select identity(int) id0,name,score into #temp3 from test1
where score >=80 and score <=100 order by name; --80~100select @a = count(*) from #temp1
select @b = count(*) from #temp2
if (@a > @b)
select a.name,a.score,b.name,b.score,c.name,c.score from #temp1 a
full outer join #temp2 b on a.id0 = b.id0 
full outer join #temp3 c on a.id0 = c.id0 
else
select a.name,a.score,b.name,b.score,c.name,c.score from #temp1 a
full outer join #temp2 b on a.id0 = b.id0 
full outer join #temp3 c on b.id0 = c.id0 drop table #temp1,#temp2,#temp3
**************************************************************************

解决方案 »

  1.   

    你的ADO的版本是不是太低了呢?这种问题可能是由于这个原因导致的!
      

  2.   

    ADO(ADOQuery)上無法執行是啥意思,具体错误是什么
      

  3.   

    本人已解決,方法如下:
    /////////declare @a int,@b int  //此句放在后面
    select identity(int) id0,name,score into #temp1 from test1
    where score <60 order by name; --不及格select identity(int) id0,name,score into #temp2 from test1
    where score >=60 and score <80 order by name; --60~80select identity(int) id0,name,score into #temp3 from test1
    where score >=80 and score <=100 order by name; --80~100declare @a int,@b int  
    select @a = count(*) from #temp1
    select @b = count(*) from #temp2
    if (@a > @b)
    select a.name,a.score,b.name,b.score,c.name,c.score from #temp1 a
    full outer join #temp2 b on a.id0 = b.id0 
    full outer join #temp3 c on a.id0 = c.id0 
    else
    select a.name,a.score,b.name,b.score,c.name,c.score from #temp1 a
    full outer join #temp2 b on a.id0 = b.id0 
    full outer join #temp3 c on b.id0 = c.id0 drop table #temp1,#temp2,#temp3多謝各位的提示