in mytable when i query
SELECT * FROM mytable WHERE adsh='0000002178-18-000009' and tag='assets'
i get this result
adsh tag ddate value
0000002178-18-000009 Assets 2016-12-31 246872000.00
0000002178-18-000009 Assets 2017-12-31 282704000.00
but i wish to have only the row containing the max(ddate) returned, the 2017-12-31 row Note there are many other different tags. But since the table holds >100k rows i wish to make sure i am doing the right query before expanding it to all rows.
I tried many different queries & variations but no cigar :/
SELECT *,max(ddate) FROM mytable WHERE adsh='0000002178-18-000009' and tag='Assets'
that return the wrong line
SELECT * FROM mytable
WHERE ddate = (select max(ddate) and adsh='0000002178-18-000009' and tag='Assets' from mytable)
that returns 0 rows
SELECT * FROM mytable
WHERE ddate = (select max(ddate) and adsh='0000002178-18-000009' and tag='Assets' from mytable)
that returns 0 rows
SELECT DISTINCT adsh,tag,ddate,value from mytable
WHERE ddate = (select max(ddate) from mytable) group by adsh
but that's not returning what i expect either
Does anyone have a idea how i can acheive this ?
Thanks a million :)