Here's a sample of the table I'm working on.........ID PART LINE RATE DTTM1 55 WW3 2500 01/01/19992 55 WW3 2200 01/01/20003 55 WW3 2150 01/01/20014 55 WW6 900 01/01/19995 55 WW6 1000 01/01/20006 55 WW6 1500 01/01/20017 55 WW7 2000 01/01/19998 55 WW7 2350 01/01/20009 55 WW7 1750 01/01/2001
I want to query for the most recent rate for each part and line (actual table contains 300 different parts for each line).i.e. the query would give the following tableID PART LINE RATE DTTM3 55 WW3 2150 01/01/20016 55 WW6 1500 01/01/20019 55 WW7 1750 01/01/2001
I'm getting confused with grouping I think.....Could someone explain why this returns all rows, rather than the above?SELECT MAX(dttm) AS DTTM, LINE, PART, RATEFROM TableNameGROUP BY LINE, PART, RATE
Thanks in advance for your help