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)
 Trying to get distinct rows

Author  Topic 

reddymade
Posting Yak Master

165 Posts

Posted - 2005-11-22 : 16:23:54
Hello,
Please, I have the following query, and trying to get the distinct records by c.CNID field

SELECT Top 3 c.ID as Modid,c.CNID,RTRIM(pg.progno) + ' ' + RTRIM(pj.projno)+ ' ' + RTRIM(ctr.contractno) AS description,C.sequenceno as Seq,'CN' as Type,C.Updated
FROM tab_ccsnetcn_log C INNER JOIN
TAB_ccsNetPrograms pg ON C.ProgID = pg.ProgID INNER JOIN
TAB_ccsNetProjects pj ON C.ProjID = pj.ProjID INNER JOIN
TAB_ccsNetContracts ctr ON C.ContractID = ctr.ContractID

Thank you very much for the help.

reddymade
Posting Yak Master

165 Posts

Posted - 2005-11-22 : 16:37:35
Sorry, I missed the Order by clause with Updated datetime datatype.

SELECT Top 3 c.ID as Modid,c.CNID,RTRIM(pg.progno) + ' ' + RTRIM(pj.projno)+ ' ' + RTRIM(ctr.contractno) AS description,C.sequenceno as Seq,'CN' as Type,C.Updated
FROM tab_ccsnetcn_log C INNER JOIN
TAB_ccsNetPrograms pg ON C.ProgID = pg.ProgID INNER JOIN
TAB_ccsNetProjects pj ON C.ProjID = pj.ProjID INNER JOIN
TAB_ccsNetContracts ctr ON C.ContractID = ctr.ContractID
ORDER BY C.Updated DESC
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-11-22 : 16:55:09
We are going to need more information in order to help you. Please provide sample data for each of your tables, DDL for the tables, and the expected result set using the sample data. See X002548's signature link for an example.

Tara Kizer
aka tduggan
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-23 : 00:05:41
In your case giving additional information is the best way to get answer

As Tara told you, refer this and post accordingly
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Madhivanan

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

- Advertisement -