Do you know what are "INNER JOIN", "OUT JOIN" in SQL???
If no, then learn those concepts first and you'll be able to solve your problem (I think).
If you do, well... can you clarify your question a little more :)
Good luck
zmariow
Junior Poster in Training
71 posts since Aug 2007
Reputation Points: 14
Solved Threads: 1
I’m new to SQL server (and databases, sql) and guess ‘cursor’ may be the way to go but I would appreciate any help. Thanks
Cursor? yuck! I have been programing SQL Server for 8 years and I have *never* used a cursor they are slooooowww and are completely contrary to set based theory. If you *have* to iterate data in a one by one scenario do it in code where it belongs not in the database. Or use a TSQL while loop or table variables.
You need to look into the GROUP BY clause of the SQL syntax.
Select
b.message_text, a.host, a.resource,
max(a.event_in_secs) as max_event_in_secs
from
a join b on a.message_num = b.message_num
group by
b.message_text, a.host, a.resource
hollystyles
Veteran Poster
1,182 posts since Feb 2005
Reputation Points: 262
Solved Threads: 68
This query will help you get all the rows you need with duplicate entries and without selecting the most current record:
SELECT A.message_text, B.event_date, B.resource
FROM A INNER JOIN B
ON A.message_num = B.message_num
It's not your end query but it's a good start :)
Good luck.
zmariow
Junior Poster in Training
71 posts since Aug 2007
Reputation Points: 14
Solved Threads: 1
hollystyles
Veteran Poster
1,182 posts since Feb 2005
Reputation Points: 262
Solved Threads: 68