注册 登录
编程论坛 SQL Server论坛

子查询出错!

kevintang 发布于 2008-03-19 21:45, 975 次点击
SELECT top 4 dbo.SJUser.SJUser_Logo, dbo.SQ_News_Doings.SQ_News_Doings_Intro, dbo.SQ_News_Doings.SQ_News_Doings_Title, dbo.SQ_News_Doings.SQ_News_Doings_UpdateTime,dbo.SJUser.SJUser_SJName_CN, dbo.SJUser.SJUser_SJName_EN,dbo.SQ_News_Doings.SQ_News_Doings_BeginTime, dbo.SQ_News_Doings.SQ_News_Doings_EndTime, dbo.SQ_News_Doings.SQ_News_Doings_CreateTime,dbo.SQ_News_Doings.SQUser_ID,dbo.SQ_News_Doings.SQ_News_Doings_ID FROM dbo.SJUser INNER JOIN dbo.SQ_News_Doings ON dbo.SJUser.SJUser_ID = dbo.SQ_News_Doings.SJUser_ID  where  dbo.SQ_News_Doings.SQ_News_Doings_ID not in ( select top 4 dbo.SQ_News_Doings.SQ_News_Doings_ID FROM dbo.SJUser INNER JOIN dbo.SQ_News_Doings ON dbo.SJUser.SJUser_ID = dbo.SQ_News_Doings.SJUser_ID  where dbo.SQ_News_Doings.SQUser_ID = '15FF7571-F0DE-492C-ADD7-B46EC771E017' and '2008-3-19' >= SQ_News_Doings_BeginTime and '2008-3-19'<= SQ_News_Doings_EndTime)  order by SQ_News_Doings_UpdateTime desc


SELECT top 4 dbo.SJUser.SJUser_Logo, dbo.SQ_News_Doings.SQ_News_Doings_Intro, dbo.SQ_News_Doings.SQ_News_Doings_Title, dbo.SQ_News_Doings.SQ_News_Doings_UpdateTime,dbo.SJUser.SJUser_SJName_CN, dbo.SJUser.SJUser_SJName_EN,dbo.SQ_News_Doings.SQ_News_Doings_BeginTime, dbo.SQ_News_Doings.SQ_News_Doings_EndTime, dbo.SQ_News_Doings.SQ_News_Doings_CreateTime,dbo.SQ_News_Doings.SQUser_ID,dbo.SQ_News_Doings.SQ_News_Doings_Top FROM dbo.SJUser INNER JOIN dbo.SQ_News_Doings ON dbo.SJUser.SJUser_ID = dbo.SQ_News_Doings.SJUser_ID  where dbo.SQ_News_Doings.SQUser_ID = '15FF7571-F0DE-492C-ADD7-B46EC771E017' and '2008-3-19' >= SQ_News_Doings_BeginTime and '2008-3-19'<= SQ_News_Doings_EndTime order by SQ_News_Doings_UpdateTime desc


这两句查询语句!是子查询 我要按日期排序!怎么查处的的后4 条还有那个日期为最新的那条数据啊!
   是不是我的ORDER BY 放错地方了啊?
  请高手帮忙
1 回复
#2
kevintang2008-03-21 09:22
日! 自己改好了!
1