473,407 Members | 2,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Issue with SELECT TOP 3 / UNIQUE

To all,

I am hoping for some insight in to this query. I have a
homepage on my Intranet that displays the three most
recent postings for a number of categories (i.e.
announcements, discussion posts, users created, calendar
events, etc). The code below finds the three most recent
posts to the discussion forums.

The problem is that if 3 users respond to the same topic
it displays the three replies. I would like it to
identify the most recent replies in unique topics so that
if 2 posts are made back to back in the same topic, it
only shows that topic once. Therefore, the homepage that
displays the three most recent postings should always
display unique topics even though the last three replies
were for the same topic.

Structure of the db is DiscCategories which have
DiscDiscussions which have DiscTopics which have
DiscReplies. (i.e. eHelp Category might have IT, Marketing
discussions. Marketing might have many topics (i.e. how
do I create an Ad) which might have many replies.)

The code I am currently using follows. I am assuming that
this may be a multi sql query using SELECT UNIQUE
tbl_Intra_DiscTopics.discTopicID but I am at a loss for
how to implement.

SELECT TOP 3 tbl_Intra_DiscReplies.discReplyDate,
tbl_Intra_DiscReplies.discTopicID,
tbl_Intra_DiscTopics.discTopicTitle,
tbl_Intra_DiscReplies.discReplyUserID,
tbl_users.userFirst, tbl_users.userLast FROM tbl_users
INNER JOIN (tbl_Intra_DiscTopics INNER JOIN
tbl_Intra_DiscReplies ON tbl_Intra_DiscTopics.discTopicID
= "tbl_Intra_DiscReplies.discTopicID) ON tbl_users.userID
= tbl_Intra_DiscReplies.discReplyUserID ORDER BY
tbl_Intra_DiscReplies.discReplyDate DESC;

Thanks,
Steve

Jul 19 '05 #1
1 1729
Hi

Instead of searching by Topic Title, I would hope that
each topic would have an ID and a parent ID (so its known
what topic the reply is linked to) so

1.) A topic with 3 back to back replies,
Select say the last 50 replies or messages in your replies
db.

Search for the top 3 most recent parent IDs in the list.
Using this, search for the most recent reply for each of
the parent IDs.

Or why not search for the top 3 messages or new topics
ordered by date where the parent iD is unique.

Not sure if this is any help to you but if it is glad to
be of some service...
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: curwen | last post by:
Hi, I'm in deep struggle with query from a huge table: what I've got is a lot of records like: _______________ numb fk1 _______________ 1231456 61 1231456 62
3
by: Jason | last post by:
I will explain (or at least try to) first and then give an example after. I need to append a number of rows from several tables into one master table. Unfortunately there are certain columns...
1
by: Darius | last post by:
I was having an issue inserting data into a table in an I-Series DB2 database. The Insert statement itself is very simple: Insert into Table1 select * from Table2 These two tables have...
8
by: -Karl | last post by:
Apparently, asp.net has a posting issue with refreshing. There seems to be several solutions to the issue but I was wondering if there is a final workaround for the issue? If so, can you please...
8
by: Jeff | last post by:
hey guys. Thanks for all the help in the past. For some reason, ASP came fairly easy to me, but putting SQL in it.. well.. I lack. Anyway, here is what I have. set bam1 = conn.execute ("select...
48
by: Jimmy | last post by:
thanks to everyone that helped, unfortunately the code samples people gave me don't work. here is what i have so far: <% Dim oConn, oRS, randNum Randomize() randNum = (CInt(1000 * Rnd) + 1) *...
10
by: shsandeep | last post by:
The ETL application loaded around 3000 rows in 14 seconds in a Development database while it took 2 hours to load in a UAT database. UAT db is partitioned. Dev db is not partitioned. the...
9
by: Kelii | last post by:
I've been trying to get this piece to work for a few hours, but have given up. I hope someone out there can help, I think the issue is relatively straightforward, but being a novice, I'm stumped....
10
by: Path9898 | last post by:
greetings. I am having an issue with a piece of code, I was hoping someone can show me where I am going wrong. Basically I select 9 rows of data out of a table that have the same item number, but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.