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
 General SQL Server Forums
 New to SQL Server Programming
 Max Value

Author  Topic 

dr223
Constraint Violating Yak Guru

444 Posts

Posted - 2010-07-21 : 12:16:34
Hi,

The following code doesn't give me the maximum value ONLy, any help please

SELECT     dbo.tblProjectPractices.ProjectPracticeID, MAX(dbo.tblBatchID.BatchID) AS BatchID
FROM dbo.tblProjectPractices INNER JOIN
dbo.tblBatchID ON dbo.tblProjectPractices.ProjectID = dbo.tblBatchID.ProjectID
GROUP BY dbo.tblProjectPractices.ProjectPracticeID, dbo.tblBatchID.BatchID, dbo.tblBatchID.ProjectID

SD_Monkey
Starting Member

38 Posts

Posted - 2010-07-21 : 12:29:39
try this one...

SELECT
a.ProjectPracticeID,MAX(b.BatchID) as [Batch ID]
FROM
tblProjectPractices a INNER JOIN tblBatchID b
ON a.ProjectID=b.ProjectID
GROUP BY a.ProjectPracticeID


A maze make you much more better
Go to Top of Page

dr223
Constraint Violating Yak Guru

444 Posts

Posted - 2010-07-21 : 12:37:31
thanks worked fine
Go to Top of Page
   

- Advertisement -