i have table similar below:
req po line cost rev 101630 p101630 1 26.48 0 101630 p101630 2 26.82 0 101630 p101630 3 17.83 0 101630 p101630 1 26.48 1 101630 p101630 2 110.00 1 101630 p101630 3 17.83 1 101630 p101630 1 52.96 2 101630 p101630 2 110.00 2 101630 p101630 3 35.66 2
how find result want this:
req po line cost rev 101630 p101630 1 52.96 2 101630 p101630 2 110.00 2 101630 p101630 3 35.66 2
i tried using didn't return correct results
select req, po, line, cost, max(rev) table po= 'p101630' group req, po, line, cost
i use (if want last revision each single req, po, line):
select req, po, line, cost ( select req, po, line, cost, row_number() on (partition req, po, line order rev desc) rn table ) rn = 1
Comments
Post a Comment