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.
| Author |
Topic |
|
hari4u6
Starting Member
12 Posts |
Posted - 2009-12-17 : 01:13:38
|
| Hello, I'm creating a forum application like SQL Team.. I've have three tables .. ForumTopic , ForumPost, ForumReply The architechure is something like this.. ForumTopic ....ForumTopicId,TopicName,Description,CreatedDate,CreatedByForumPost-ForumPostId,ForumTopicId,Subject,Description,PostDate,CreatedByand ForumReply--ForumReplyId,ForumPostId,ReplyBy,ReplyDate,Description..These are the three tables am using..What I want is .. The stored procedure with no. of threads , last post , postedby,datetime, in a Topic Anybody please help mee.. |
|
|
cat_jesus
Aged Yak Warrior
547 Posts |
Posted - 2009-12-17 : 08:53:59
|
| Try thisDeclare @threads as intselect @threads = count(*) from ForumTopicWith LatestPost (TopicID,PostID) as(Select ForumTopicID,Max(forumpostid) from ForumPost group by ForumTopicID)Select @threads as NumberofThreads, B.TopicName,C.PostedBy as lastPoster,C.PostDateFrom LatestPost AJoin ForumTopic B on A.ForumTopicID = B.ForumTopicIDJoin ForumReply C on C.ForumPostID = A.PostIDAn infinite universe is the ultimate cartesian product. |
 |
|
|
hari4u6
Starting Member
12 Posts |
Posted - 2009-12-18 : 06:30:36
|
| thank you for the reply, It didnt help Sir. I'm getting error in no. of threads. Hari. |
 |
|
|
|
|
|
|
|