sql - Get MAX() on repeating IDs -
this how query results currently. how can max() value each unique id ?
ie,
for 5267139 8. 5267145 4 5267136 5 5267137 8 5267137 2 5267139 8 5267139 5 5267139 3 5267141 4 5267141 3 5267145 4 5267145 3 5267146 1 5267147 2 5267152 3 5267153 3 5267155 8 select distinct st.scoreid, st.scoretrackingtypeid scoretrackingtype stt left join scoretracking st on stt.scoretrackingtypeid = st.scoretrackingtypeid order st.scoreid, st.scoretrackingtypeid desc 
group by partition table separate blocks based on column(s) specify. can apply aggregate function (max in case) against each of blocks -- behavior applies default below syntax:
select first_column, max(second_column) max_second_column table group first_column edit: based on query above, looks don't need scoretrackingtype table @ all, leaving in place, use:
select st.scoreid, max(st.scoretrackingtypeid) scoretrackingtypeid scoretrackingtype stt left join scoretracking st on stt.scoretrackingtypeid = st.scoretrackingtypeid group st.scoreid order st.scoreid the group by obviate need distinct, max give value looking for, , order by still apply, since there single scoretrackingtypeid value each scoreid can pull out of ordering.
Comments
Post a Comment