In SQL Server 2016, say I have a simple table defined as:
CREATE TABLE MyTable (
    ID int NOT NULL,
    Timestamp timestamp,
    Category varchar(255),
    Value decimal(10,2),
    PRIMARY KEY (ID) 
);
I am trying to find the latest value of every unique category. Currently I am using the following query multiple times:
SELECT TOP (1) Category, Value FROM MyTable WHERE Category =
'WhateverCategory1' ORDER BY Timestamp DESC
This works, however the categories need to be hardcoded in the query. Also, there are multiple result sets, one for each category. How would I find the latest value for every unique category, all in the same result set?
 
    