Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7080375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:47:16+00:00 2026-05-28T06:47:16+00:00

I know I have duplicate results from this query because the tables ReleaseHistory and

  • 0

I know I have duplicate results from this query because the tables ReleaseHistory and IterationHistory have multiple records per ReleaseID and IterationID. I would like to only select the records with max date from dbo.ReleaseHistory and dbo.IterationHistory. How would I do that in this query? SQL SERVER 2008

SELECT     dbo.Assignable.AssignableID AS ID,
           dbo.EntityType.Abbreviation AS Entity, 
           dbo.General.Name, dbo.Assignable.Effort, 
           dbo.Assignable.EffortCompleted, 
           dbo.Assignable.EffortToDo, 
           dbo.EntityState.Name AS State, 
           dbo.ReleaseHistory.Name AS Release,   
           dbo.IterationHistory.Name AS Iteration, 
           dbo.General.CustomField3 AS [Scrum Team]
FROM       dbo.Assignable INNER JOIN
           dbo.General ON dbo.Assignable.AssignableID = 
             dbo.General.GeneralID INNER JOIN
           dbo.EntityType ON dbo.General.EntityTypeID = 
             dbo.EntityType.EntityTypeID INNER JOIN
           dbo.EntityState ON dbo.Assignable.EntityStateID = 
             dbo.EntityState.EntityStateID AND 
           dbo.EntityType.EntityTypeID = 
             dbo.EntityState.EntityTypeID INNER JOIN
           dbo.ReleaseHistory ON dbo.Assignable.ReleaseID = 
             dbo.ReleaseHistory.ReleaseID INNER JOIN
           dbo.IterationHistory ON 
             dbo.Assignable.IterationID = 
             dbo.IterationHistory.IterationID LEFT OUTER JOIN
           dbo.CustomField ON dbo.General.CustomField3 = 
             dbo.CustomField.CustomFieldID
WHERE     (dbo.Assignable.ProjectID = 4054)
GROUP BY dbo.Assignable.AssignableID, 
           dbo.EntityType.Abbreviation, 
           dbo.General.Name, 
           dbo.Assignable.Effort, 
           dbo.Assignable.EffortCompleted, 
           dbo.Assignable.EffortToDo, 
           dbo.EntityState.Name, 
           dbo.ReleaseHistory.Name, 
           dbo.IterationHistory.Name, 
           dbo.General.CustomField3
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:47:16+00:00Added an answer on May 28, 2026 at 6:47 am

    Brian,

    I am amusing you are doing this in MS SQL and there will always be at least one record in ReleaseHistory and IterationHistory tables. If assumptions are correct then you can simply use CROSS APPLY to get top 1 record from both tables.

    SELECT
        dbo.Assignable.AssignableID AS ID ,
        dbo.EntityType.Abbreviation AS Entity ,
        dbo.General.Name ,
        dbo.Assignable.Effort ,
        dbo.Assignable.EffortCompleted ,
        dbo.Assignable.EffortToDo ,
        dbo.EntityState.Name AS State ,
        Release ,
        Iteration ,
        dbo.General.CustomField3 AS [Scrum Team]
    FROM
        dbo.Assignable 
    
        INNER JOIN dbo.General ON  dbo.Assignable.AssignableID = dbo.General.GeneralID 
        INNER JOIN dbo.EntityType ON  dbo.General.EntityTypeID = dbo.EntityType.EntityTypeID 
        INNER JOIN dbo.EntityState ON  dbo.Assignable.EntityStateID = dbo.EntityState.EntityStateID 
            AND dbo.EntityType.EntityTypeID = dbo.EntityState.EntityTypeID 
        CROSS APPLY( SELECT TOP 1 name Release FROM ReleaseHistory WHERE ReleaseID = Assignable.ReleaseID ORDER BY MaxDateColumn) a
        CROSS APPLY( SELECT TOP 1 name Iteration FROM IterationHistory WHERE IterationID = Assignable.IterationID ORDER BY MaxDateColumn) b
        LEFT OUTER JOIN dbo.CustomField ON  dbo.General.CustomField3 = dbo.CustomField.CustomFieldID
    WHERE
        ( dbo.Assignable.ProjectID = 4054 )
    GROUP BY
        dbo.Assignable.AssignableID ,
        dbo.EntityType.Abbreviation ,
        dbo.General.Name ,
        dbo.Assignable.Effort ,
        dbo.Assignable.EffortCompleted ,
        dbo.Assignable.EffortToDo ,
        dbo.EntityState.Name ,
        dbo.ReleaseHistory.Name ,
        dbo.IterationHistory.Name ,
        dbo.General.CustomField3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Retrieve column names from java.sql.ResultSet I have query which returns the result
I have two arrays (records returned from a database query) that I'm merging. I
Possible Duplicate: UIDevice uniqueIdentifier Deprecated - What To Do Now? I know there have
Possible Duplicate: How to know if Process.Start() is successful? I have a process similar
I have NSArray and I want to remove duplicates from it. I know that
I know there have been some similar questions to this, but they haven't helped
Possible Duplicate: php date compare I have a date that I take from the
I want a SQL like query and have results that start with the input
Possible Duplicate: Spring's Stored Procedure - results coming back from procedure always empty. I
I have a query as follows: SELECT * FROM (SELECT * FROM persons ORDER

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.