Click here to Skip to main content
15,913,027 members
Home / Discussions / Database
   

Database

 
GeneralRe: Retrieving the lastest instance of a record Pin
#realJSOP20-Mar-10 5:02
professional#realJSOP20-Mar-10 5:02 
GeneralRe: Retrieving the lastest instance of a record Pin
i.j.russell20-Mar-10 8:48
i.j.russell20-Mar-10 8:48 
GeneralRe: Retrieving the lastest instance of a record Pin
#realJSOP21-Mar-10 2:01
professional#realJSOP21-Mar-10 2:01 
GeneralRe: Retrieving the lastest instance of a record Pin
i.j.russell21-Mar-10 2:32
i.j.russell21-Mar-10 2:32 
GeneralRe: Retrieving the lastest instance of a record Pin
#realJSOP21-Mar-10 10:41
professional#realJSOP21-Mar-10 10:41 
GeneralRe: Retrieving the lastest instance of a record Pin
i.j.russell21-Mar-10 11:28
i.j.russell21-Mar-10 11:28 
GeneralRe: Retrieving the lastest instance of a record Pin
#realJSOP21-Mar-10 12:24
professional#realJSOP21-Mar-10 12:24 
GeneralRe: Retrieving the lastest instance of a record Pin
i.j.russell21-Mar-10 12:45
i.j.russell21-Mar-10 12:45 
I think that this is what you need;

SELECT a.*,
	lm.*
FROM dbo.Articles AS a
	CROSS APPLY 
		(SELECT TOP 1 m.*
		 FROM dbo.ArticleMetrics AS m
		 WHERE m.ArticleId = a.ArticleId
		 ORDER BY m.DateScraped DESC) AS lm


I would also add a compound primary key to ArticleMetrics on ArticleId, DateScraped.
GeneralRe: Retrieving the lastest instance of a record Pin
#realJSOP22-Mar-10 0:05
professional#realJSOP22-Mar-10 0:05 
GeneralRe: Retrieving the lastest instance of a record Pin
i.j.russell22-Mar-10 0:13
i.j.russell22-Mar-10 0:13 
GeneralRe: Retrieving the lastest instance of a record Pin
#realJSOP21-Mar-10 2:26
professional#realJSOP21-Mar-10 2:26 
AnswerRe: Retrieving the lastest instance of a record [ SOLVED] Pin
Luc Pattyn20-Mar-10 4:49
sitebuilderLuc Pattyn20-Mar-10 4:49 
GeneralRe: Retrieving the lastest instance of a record [ SOLVED] Pin
#realJSOP20-Mar-10 6:22
professional#realJSOP20-Mar-10 6:22 
QuestionT-SQL - Select with relationships Pin
#realJSOP20-Mar-10 2:50
professional#realJSOP20-Mar-10 2:50 
AnswerRe: T-SQL - Select with relationships Pin
amer shammout20-Mar-10 4:25
amer shammout20-Mar-10 4:25 
AnswerRe: T-SQL - Select with relationships Pin
i.j.russell20-Mar-10 4:28
i.j.russell20-Mar-10 4:28 
QuestionSQL server encryption Pin
Central_IT19-Mar-10 6:00
Central_IT19-Mar-10 6:00 
QuestionRe: SQL server encryption Pin
Chris Meech19-Mar-10 8:20
Chris Meech19-Mar-10 8:20 
AnswerRe: SQL server encryption Pin
Jörgen Andersson19-Mar-10 8:59
professionalJörgen Andersson19-Mar-10 8:59 
GeneralRe: SQL server encryption Pin
Chris Meech19-Mar-10 11:26
Chris Meech19-Mar-10 11:26 
AnswerRe: SQL server encryption Pin
Jörgen Andersson19-Mar-10 8:56
professionalJörgen Andersson19-Mar-10 8:56 
QuestionSQL Server Interview Question and Answers - Need your valuable comments, real experience and suggestions Pin
pinaldave18-Mar-10 23:07
pinaldave18-Mar-10 23:07 
AnswerRe: SQL Server Interview Question and Answers - Need your valuable comments, real experience and suggestions Pin
i.j.russell19-Mar-10 2:03
i.j.russell19-Mar-10 2:03 
GeneralRe: SQL Server Interview Question and Answers - Need your valuable comments, real experience and suggestions Pin
pinaldave19-Mar-10 2:32
pinaldave19-Mar-10 2:32 
GeneralRe: SQL Server Interview Question and Answers - Need your valuable comments, real experience and suggestions Pin
Jörgen Andersson19-Mar-10 4:11
professionalJörgen Andersson19-Mar-10 4:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.