sql - Find the last row matches a criteria -
i need create sql query sql server find last row matches criteria.
i need find last dauditdate
person if tech1
or tech2
or tech3
233
. in case need 7/15/2015's row dauditdate
. can please help.any appreciated.
ipersonid snamefirst snamelast dauditupdate tech1 tech2 tech3 75605 jeff plutter 10/29/2013 233 0 0 75605 jeff plutter 10/29/2013 233 0 0 75605 jeff plutter 7/15/2014 233 0 0 75605 jeff plutter 7/15/2014 15 0 0 75605 jeff plutter **7/15/2014** 15 **233** 259 75605 jeff plutter 7/25/2014 15 233 259 1377905 jeff plutter 1/31/2015 15 233 0
i tried using top 1 record order dauditupdate desc
, not working.
i assume using microsoft sql server.
unfortunately there no in-built last-method.
but use ordering
, top
last record..
select top 1 * your_table (tech1 = 233 or tech2 = 233 or tech3 = 233) order ipersonid desc
Comments
Post a Comment