I need to get the row with latest date in my table. I have tried using where rownum = 1 as well as using max function but I dont seem to get the correct result.
This is what I have tried, this gives me more than one rows, I want the row with the max date:
SELECT * FROM (SELECT col1,col2,coldate3,max(colDate3) 
over (partition by coldate3) max_date FROM MY_TABLE 
WHERE 
TRIM(col1) = TRIM('abc') 
AND TRIM(col2) = TRIM('efg') )
where coldate3= max_date;
I have also tried this, this gives me the max date but value of col1 is of some other row:
 SELECT MY_TABLE.TARIFF 
FROM MY_TABLE 
WHERE ROWNUM = 1 
AND TRIM(MY_TABLE.col1) = TRIM(:ls_col1) 
AND TRIM(MY_TABLE.col2) = TRIM(:ls_col2) 
ORDER BY coldate3 desc
What am I doing wrong.
 
    