oracle - SQL - Get max date from dd/mm/yyyy formated column -


i have db table have column name statusdate. type of column varchar2 , column have data in dd/mm/yyyy format. , want recent date(max date). used max() method not give correct result, example consider following dates

31/08/2014

01/09/2016

after using max(statusdate) result 31/08/2014. i'm using oracle db.

i'm try use following quarry since above problem give incorrect results

select * my_db.my_table t inner join (     select clientname, max(statusdate) maxdate     from my_db.my_table     group clientname ) tm on t.clientname = tm.clientname , t.statusdate = tm.maxdate 

please can suggest proper way thank you

moral: don't store dates strings. databases have built-in types reason.

so, convert proper date , take max, don't need join this:

select t.* (select t.*,              rank() on (partition client_name                           order to_date(statusdate, 'dd/mm/yyyy') desc                          ) seqnum       my_db.my_table t      ) t seqnum = 1; 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -