0

I have a table like this

Entry Name Color Usage
1 A Red 0.5
2 A Red 0.8
3 A Red 1.5
4 B Blue 1.3
5 B Blue 0.8
6 B Blue 0.6

So, I want to get the latest value of usage from the same record like

A, Red, 1.5  
B, Blue, 0.6  

I've tried

SELECT MAX([Entry]) AS [Entry], [Name], [Color], [Usage]  
FROM [ColorUsage]  
GROUP BY [Name], [Color, [Usage]

The problem with that is, I got all the [Usage] value while I only wanted the latest value
If I don't group the [Usage] I can get it right but I need [Usage] value

Dale K
  • 25,246
  • 15
  • 42
  • 71
Rohad Bokhar
  • 104
  • 9
  • so here's your query `SELECT T.Name,T.Color,T.usage, R.Entry FROM ( SELECT Name, color,MAX(Entry)AS Entry FROM Test GROUP BY Name, color ) R INNER JOIN Test T ON T.Name = R.Name AND T.color=R.color AND T.Entry = R.Entry ` – Akshay Phadke Aug 09 '22 at 04:22
  • @akshayphadke please don't provide answers as comments. – Dale K Aug 09 '22 at 05:04

0 Answers0