sql server - SQL return max value only -
i have done basic queries using max 1 has little more it. using ssms 2012. need include group or distinct.
select statement -
select a.year1, a.periodid gpstj..sy40100 a.closed = 0 , a.periodid <> 0 , a.series = 5 this returns following results -
year1 periodid 2015 12 2015 12 2016 1 2016 1 2016 2 2016 2 i want return 1 row, maximum value in year column first, , maximum period id -
year1 periodid 2016 2 thanks
just ordering top (1)
select top (1) a.year1, a.periodid gpstj..sy40100 a.closed = 0 , a.periodid <> 0 , a.series = 5 order a.year1 desc, a.periodid desc
Comments
Post a Comment