I just tried to retrieve max record of each day based on timestamp. For example:
Dummy date
id type timestamp , etc
1 a 07/10/2022 12:54:59
2 a 07/10/2022 12:50:59
3 b 05/10/2022 12:54:59
4 c 05/10/2022 10:54:59
5 d 01/09/2022 12:54:59
6 c 01/09/2022 12:54:50
Expected result
id type timestamp , etc
1 a 07/10/2022 12:54:59
3 b 05/10/2022 12:54:59
5 d 01/09/2022 12:54:59
I have written below SQL query but it's not working as expected:
select c.code, to_char (p.TIMESTAMP, 'DD/MM/YYYY HH24:MI:ss') as time_stamp, p.TYPE1
from table1 p
INNER JOIN table2 c on c.id3 =p.id2
where p.id1= 1234
and p.id2 = 1
and p.type1 = 'X'
and c.CODE = 'XYZ'
and to_char (p.TIMESTAMP, 'DD/MM/YYYY') between '01/05/2011' and '30/05/2011'
order by c.code, p.id desc;