Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 select 3 series from one view

Author  Topic 

maxim
Yak Posting Veteran

51 Posts

Posted - 2007-01-12 : 11:40:40
Hello!

I have a view in my sql server and i want to list in one single table values according three parameters.

First Order by dateadded and get top 5,
second Order by TopicLastReplyDate and get top 5,
last Order by views and get top 5

I tried:

SELECT (
(SELECT Subject from v_forums_topics order by AddedDate DESC) as lastTsubj,
(SELECT MemberName from v_forums_topics order by AddedDate DESC) as lastTautor,
(SELECT Subject from v_forums_topics order by TopicLastReplyDate DESC) as lastTRsubj,
(SELECT MemberName from v_forums_topics order by TopicLastReplyDate DESC) as lastTRautor,
(SELECT Subject from v_forums_topics order by Views DESC) as lastVsubj,
(SELECT MemberName from v_forums_topics order by Views DESC) as lastVautor,
(SELECT Views from v_forums_topics order by Views DESC) as lastVviews
)
[code]


But i don't have sucess with this query! :(

With this i'm consulting my "v_forums_topics" 7 times and this view is very heavy!

So It's possible to have the table

lastTsubj lastTautor lastTRsubj lastTRautor lastVsubj lastVautor lastVviews
1 ..
2 ..
3 ..
4 ..
5 ..

using some light query?

Thank you very much!
   

- Advertisement -