First post, please be beautiful. [SQL Server 2014]
I am currently running selection against a table that looks like below
select ExerciseCultures.Name, max (convert (decimal (10,2), cast(weight as float))) as [Max Weight (KG)] from workoutsessions join ExerciseCultures on workoutsessions.ExerciseID = ExerciseCultures.ExerciseID group by ExerciseCultures.Name
Which returns 31 rows, one for each exercise identifier, showing the maximum "weight" value for each of them.
I need an extra column that also shows a date for each of these rows. The date column is the column of the workoutsessions table next to each row.
I tried to add this date column using below:
select ExerciseCultures.Name, max (convert (decimal (10,2), cast(weight as float))) as [Max Weight (KG)], workoutsessions.date from workoutsessions join ExerciseCultures on workoutsessions.ExerciseID = ExerciseCultures.ExerciseID group by ExerciseCultures.Name, workoutsessions.date
But this returns 286 rows - all rows in the parent table. I need the original query results only with their corresponding date from the workoutsessions table.
Any thoughts?
Many thanks
source share