我的查询返回如下数据:
$percent_complete
但是,我真的只关心获得Type A,B和C的最新数据。这样我的回报会是这样的:
ID | ProcessID | Type| Value | Date
--------------------------------------------------
1 | 2 | A | 10 | 2/23/2016 10:10:42 AM
1 | 2 | B | 20 | 2/23/2016 10:10:42 AM
1 | 2 | C | 30 | 2/23/2016 10:10:42 AM
1 | 1 | A | 11 | 1/6/2016 12:48:04 PM
1 | 1 | B | 21 | 1/6/2016 12:48:04 PM
1 | 1 | C | 31 | 1/6/2016 12:48:04 PM
2 | 4 | A | 10 | 7/21/2016 11:28:22 AM
2 | 4 | B | 20 | 7/21/2016 11:28:22 AM
2 | 4 | C | 30 | 7/21/2016 11:28:22 AM
2 | 3 | A | 11 | 6/21/2016 09:41:07 AM
2 | 3 | B | 21 | 6/21/2016 09:41:07 AM
2 | 3 | C | 31 | 6/21/2016 09:41:07 AM
我尝试在select子句中使用max,但这不起作用。
这是我的sql,仅限于示例一个“ID”,以及实际返回的示例:
ID | ProcessID | Type| Value | Date
--------------------------------------------------
1 | 2 | A | 10 | 2/23/2016 10:10:42 AM
1 | 2 | B | 20 | 2/23/2016 10:10:42 AM
1 | 2 | C | 30 | 2/23/2016 10:10:42 AM
2 | 4 | A | 10 | 7/21/2016 11:28:22 AM
2 | 4 | B | 20 | 7/21/2016 11:28:22 AM
2 | 4 | C | 30 | 7/21/2016 11:28:22 AM
返回:
select f.folderrsn,fpi.processrsn,fpi.infocode, fpi.infovalue, fp.enddate
from folderprocessinfo fpi
join folderprocess fp on fp.processrsn = fpi.processrsn
join folder f on f.folderrsn = fp.folderrsn
where fpi.infocode in (51437,51438,51439)
and trunc(f.issuedate) > '01-JAN-16'
and not fpi.infovalue is null
and f.folderrsn = 11179547 --limited to one "ID" for example
order by fp.enddate asc
答案 0 :(得分:2)
您可以使用O(m)
:
row_number()