daviegravy
Programmer
I need help with my query.
I have records that have the same IEPOrderNumber but different ID's. I want to retrieve just records where ID is the MAX of all those ID's per IEPOrderNumber. Can anyone help me get my desired results? Thanks so much!
Code:
SELECT dbo.DataEnrichmentRequirements.IEPOrderNumber, MAX(dcuser.RunBooks.ID) AS IDField, dcuser.RunBooks.RunBookName, dbo.Client_overview.wfg_flowsheet, dbo.Client_overview.wfg_flow, dbo.DataEnrichmentRequirements.IBEEnvironmentProd
FROM dcuser.RunBooks INNER JOIN dbo.Client_overview ON dcuser.RunBooks.OverviewID = dbo.Client_overview.OverviewID INNER JOIN dbo.DataEnrichmentRequirements ON dcuser.RunBooks.RunBookID = dbo.DataEnrichmentRequirements.RunbookId
WHERE (dbo.DataEnrichmentRequirements.IEPOrderNumber IS NOT NULL) AND (dbo.DataEnrichmentRequirements.IBEEnvironmentProd = 'on')
GROUP BY dbo.DataEnrichmentRequirements.IEPOrderNumber, dbo.Client_overview.wfg_flowsheet, dcuser.RunBooks.RunBookName,
dbo.Client_overview.wfg_flow, dbo.DataEnrichmentRequirements.IBEEnvironmentProd
I have records that have the same IEPOrderNumber but different ID's. I want to retrieve just records where ID is the MAX of all those ID's per IEPOrderNumber. Can anyone help me get my desired results? Thanks so much!