Hi All,
I am (attempting to) write a select query where I want to return distinct rows based on a max/distinct criteria.
please see the below query for my WIP thus far:
select lintitemnumber as IPN, curcost as CurCost, dtmwhen as CurCostDate
from podetail pod
where dtmwhen = (select max(dtmwhen) from podetail pod2 where pod.lintitemnumber = pod2.lintitemnumber)
order by lintitemnumber
I am only seeking to return distinct lintitemnumbers, with curcosts that correspond with the max 'dtmwhen' for that row
FYI. the table has 5 columns, three of which are the 'lintitemnumber', 'curcost' and 'dtmwhen' columns.
any assistance would be greatly appreciated.
I am (attempting to) write a select query where I want to return distinct rows based on a max/distinct criteria.
please see the below query for my WIP thus far:
select lintitemnumber as IPN, curcost as CurCost, dtmwhen as CurCostDate
from podetail pod
where dtmwhen = (select max(dtmwhen) from podetail pod2 where pod.lintitemnumber = pod2.lintitemnumber)
order by lintitemnumber
I am only seeking to return distinct lintitemnumbers, with curcosts that correspond with the max 'dtmwhen' for that row
FYI. the table has 5 columns, three of which are the 'lintitemnumber', 'curcost' and 'dtmwhen' columns.
any assistance would be greatly appreciated.