How to select distinct? not select duplicated row I have 2 table

select DISTINCT (B.MAIN_ID), A.NAME,  A.NAME_ID, A.CREATED_DATE 
 from FAMILY A, ADDRESS B where B.F_ID = A.N_ID


result: 

MAIN_ID   |  Name     |  NAME_ID | CREATED_DATE 
100       |  Erica    |  254     | 20190808-01:02:01
100       |  Erica    |  245     | 20190808-00:01:01
300       |  Eden     |  331     | 20190808-00:03:34


I want to be remove duplicated rows 'MAIN_ID' by created date, I need last created record. How can I do this? thanks

MAIN_ID   |  Name     |  NAME_ID | CREATED_DATE 
100       |  Erica    |  254     | 20190808-01:02:01
300       |  Eden     |  331     | 20190808-00:03:34
You can use ROW_NUMBER() ranking function and a subquery (derived table or CTE):

WITH
  cte AS
  ( SELECT
      B.MAIN_ID, A.NAME, A.NAME_ID, A.CREATED_DATE,
      ROW_NUMBER() OVER (PARTITION BY B.MAIN_ID
                         ORDER BY A.CREATED_DATE DESC)
        AS RN
    FROM
      FAMILY A JOIN ADDRESS B ON B.F_ID = A.N_ID
  )
SELECT MAIN_ID, NAME, NAME_ID, CREATED_DATE
FROM cte
WHERE RN = 1 ;