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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Select join to bring the top 3 rows by datetime

Author  Topic 

reddymade
Posting Yak Master

165 Posts

Posted - 2005-11-21 : 12:49:17
I am trying make a join and get last 3 records lastmodified by datetime.
Can you please tell me how do i need to make a join:


SELECT c.CNID,p.projno
FROM tab_cn c, tab_projects p where c.projid = p.projid and
(
select Top 3 *
from TAB_CN
ORDER BY last_modified DESC
) X
ORDER BY last_modified ASC


Thank you very much for the help.




spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-11-21 : 12:54:04
http://weblogs.sqlteam.com/mladenp/archive/2005/08/01/7421.aspx
point 2

Go with the flow & have fun! Else fight the flow
Go to Top of Page

reddymade
Posting Yak Master

165 Posts

Posted - 2005-11-21 : 13:02:43
Hello Mr. Spirit,
Its not a beginner's question, the one i asked. Please if you know, try to answer.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-11-21 : 13:15:30
so basicaly you just want this?
SELECT Top 3 c.CNID,p.projno
FROM tab_cn c join tab_projects p on c.projid = p.projid
ORDER BY last_modified DESC

Go with the flow & have fun! Else fight the flow
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-22 : 00:02:05
quote:
Originally posted by reddymade

I am trying make a join and get last 3 records lastmodified by datetime.
Can you please tell me how do i need to make a join:


SELECT c.CNID,p.projno
FROM tab_cn c, tab_projects p where c.projid = p.projid and
(
select Top 3 *
from TAB_CN
ORDER BY last_modified DESC
) X
ORDER BY last_modified ASC


Thank you very much for the help.







Did your query give any error or unexpected result?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-11-22 : 05:09:40
his query never worked...

Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -