Skip to content
Advertisement

Tag: max

Return value at max date for a particular id

Here’s my sql server table This seems like it should be easy to do, but I don’t know why I’m stuck. I’d like to select ONLY the max(date) and value at that max(date) for each id. I want to ignore all other dates that aren’t the max(date) with respect to each id. Here’s what I’d like the table to look

How to use “Partition By” or “Max”?

I’ve the following table (my_data): what is the best / smallest SQL statement to retrieve only the data related to the highest year and grouped by ‘X’ , like this: Note that this result table will be used in a join. Answer

MAX on columns generated by SUM and GROUP BY

I’m trying to get the MAX on a column which is generated dynamically using the SUM statement. The SUM statement is used together with the ‘GROUP by’ syntax. This is the original query, however it needs to be modified to work with grouping, sums and of course MAX. As you can see SUM is adding all the values inside video_plays

Advertisement