sql语句问题!
在sql查询分析器中执行下面语句
select counts=(count(*)) ,filmnames=filmname into #s from view_userlog group by filmname
--select * from #t order by counts desc
select top 10 t.*,#s.counts from view_userlog t join #s on t.filmname=#s.filmnames where (not
EXISTS(select filmname from view_userlog where id>t.id and filmname=t.filmname)) and t.parent=61 order by counts desc
如果where中任意少一个条件如去掉"t.parent=61"就能执行成功,但只在两个条件都在就不能执行,这是怎么回事呀?怎么解决,各位大虾帮帮忙!
问题点数:50、回复次数:4Top
1 楼casoon(五月人)回复于 2005-08-02 16:46:29 得分 0
view_userlog结构
id int 4
loginid nvarchar 20
filmname nvarchar 50
watchtime datetime 8
Name_cn1 nvarchar 50
Parent int 4
SmallImg nvarchar 100
Top
2 楼libin_ftsafe(子陌红尘:TS for Banking Card)回复于 2005-08-02 16:58:49 得分 0
什么错误?
楼下的查询是可以执行的:
----------------------------------------------------------------------------------
create table #view_userlog(
id int,
loginid nvarchar(20),
filmname nvarchar(50),
watchtime datetime,
Name_cn1 nvarchar(50),
Parent int,
SmallImg nvarchar(100))
select counts=(count(*)) ,filmnames=filmname into #s from #view_userlog group by filmname
select
top 10 t.*,
#s.counts
from
#view_userlog t
join
#s
on
t.filmname=#s.filmnames
where
not EXISTS(select filmname from #view_userlog where id>t.id and filmname=t.filmname)
and
t.parent=61
order by
counts descTop
3 楼casoon(五月人)回复于 2005-08-02 17:03:18 得分 0
也没提示错误,就是显示正在执行查询语句!
要是少一个条件的话,执行结果马上就显示出来!Top
4 楼casoon(五月人)回复于 2005-08-02 17:08:40 得分 0
select counts=(count(*)) ,filmnames=filmname into #mm from view_userlog group by filmname
select id=identity(int,1,1),filmname=filmname,watchtime=watchtime,name_cn1=name_cn1,parent=parent,smallimg=smallimg into #films from view_userlog ss where
(not
EXISTS(select filmname from view_userlog where id>ss.id and filmname=ss.filmname))
select top 10 #films.*,#mm.counts from #films join #mm on #films.filmname=#mm.filmnames where #films.parent=61 order by #mm.counts desc
drop table #films
drop table #mm
这样就可行,也不知道是怎么回事!Top




