Click here to Skip to main content
15,886,080 members
Home / Discussions / Database
   

Database

 
GeneralRe: How to get the first rows of a relational table (depending of the last date of change) Pin
fracalifa16-Jul-08 3:01
fracalifa16-Jul-08 3:01 
GeneralRe: How to get the first rows of a relational table (depending of the last date of change) Pin
A Wong16-Jul-08 3:15
A Wong16-Jul-08 3:15 
GeneralRe: How to get the first rows of a relational table (depending of the last date of change) Pin
fracalifa16-Jul-08 3:32
fracalifa16-Jul-08 3:32 
GeneralRe: How to get the first rows of a relational table (depending of the last date of change) Pin
A Wong16-Jul-08 3:41
A Wong16-Jul-08 3:41 
GeneralRe: How to get the first rows of a relational table (depending of the last date of change) Pin
fracalifa16-Jul-08 4:10
fracalifa16-Jul-08 4:10 
GeneralRe: How to get the first rows of a relational table (depending of the last date of change) Pin
A Wong16-Jul-08 4:38
A Wong16-Jul-08 4:38 
GeneralRe: How to get the first rows of a relational table (depending of the last date of change) Pin
A Wong16-Jul-08 4:50
A Wong16-Jul-08 4:50 
AnswerRe: How to get the first rows of a relational table (depending of the last date of change) Pin
leoinfo16-Jul-08 4:29
leoinfo16-Jul-08 4:29 
You should ALWAYS provide the actual fields for each table to avoid misunderstandings.

This should solve the problem...

;WITH LatestSells AS (
	SELECT s1.* 
	FROM dbo.Sells AS s1
	INNER JOIN (
		SELECT DISTINCT Customer_ID
			, (	SELECT TOP 1 Sell_ID 
				FROM dbo.Sells 
				WHERE Customer_ID = sx.Customer_ID 
				ORDER BY Sell_Date DESC 
			  ) AS Sell_ID
		FROM dbo.Sells AS sx
	) AS s2 ON s1.Customer_ID = s2.Customer_ID AND s1.Sell_ID = s2.Sell_ID
)
SELECT c.*, s.*
FROM  dbo.Customers			AS c
LEFT OUTER JOIN LatestSells AS s
ON c.Customer_ID = s.Customer_ID

AnswerRe: How to get the first rows of a relational table (depending of the last date of change) Pin
leoinfo16-Jul-08 4:39
leoinfo16-Jul-08 4:39 
GeneralRe: How to get the first rows of a relational table (depending of the last date of change) Pin
fracalifa16-Jul-08 4:56
fracalifa16-Jul-08 4:56 
QuestionHow to Make Application to Sync on Remote Site Pin
Nassoro Ally16-Jul-08 0:39
Nassoro Ally16-Jul-08 0:39 
QuestionReports are not visible on client machine Pin
meetaqadir15-Jul-08 20:54
meetaqadir15-Jul-08 20:54 
QuestionOLEDB with Excel problem Pin
acroitoriu15-Jul-08 20:52
acroitoriu15-Jul-08 20:52 
AnswerRe: OLEDB with Excel problem Pin
acroitoriu15-Jul-08 21:23
acroitoriu15-Jul-08 21:23 
Questionfacing probs in nested cursor Pin
Member 387988115-Jul-08 19:56
Member 387988115-Jul-08 19:56 
AnswerRe: facing probs in nested cursor Pin
Alsvha15-Jul-08 23:28
Alsvha15-Jul-08 23:28 
Questionbytes retrieval Pin
vicki52815-Jul-08 18:19
vicki52815-Jul-08 18:19 
AnswerRe: bytes retrieval Pin
Alsvha15-Jul-08 23:28
Alsvha15-Jul-08 23:28 
QuestionHow do i convert a varchar field into the datetime data type Pin
Rameez Raja15-Jul-08 18:12
Rameez Raja15-Jul-08 18:12 
AnswerRe: How do i convert a varchar field into the datetime data type Pin
Alsvha15-Jul-08 23:31
Alsvha15-Jul-08 23:31 
QuestionDATABASE CONNECTIVITY Pin
murphy7715-Jul-08 15:58
murphy7715-Jul-08 15:58 
AnswerRe: DATABASE CONNECTIVITY Pin
Ashfield15-Jul-08 21:45
Ashfield15-Jul-08 21:45 
QuestionConnecting to an ODBC DataSource Pin
ffowler15-Jul-08 14:17
ffowler15-Jul-08 14:17 
QuestionDatabase Publishing Wizard alternatives Pin
Todd Smith15-Jul-08 9:15
Todd Smith15-Jul-08 9:15 
AnswerRe: Database Publishing Wizard alternatives Pin
Alsvha15-Jul-08 23:34
Alsvha15-Jul-08 23:34 

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.