我不得不在Oracle SQL的每一行中显示最后一条记录的结果
go get github.com/iiinsomnia/yiigo@v3.0.0: unexpected end of JSON input
我争吵的是
**brand** **result** **year_month**
nike 200 2018-01
nike 200 2018-02
nike 200 2018-03
nike 300 2018-04
根据上个月的记录,我必须每月传播我在BIG MNC访谈中遇到的这个问题
答案 0 :(得分:1)
像这样吗?
partition
确保每个品牌都有自己的结果order by
告诉它获取属于最后一个result
的{{1}}值我修改了输入数据,以显示year_month
作为最后一个50
的值并不那么明显。
year_month
答案 1 :(得分:0)
select brand,
(select result
from (
select result
from your_table
order by to_date(year_month,'yyyy-mm') desc
)
where rownum = 1
) result,
year_month
from your_table;
答案 2 :(得分:0)
SELECT brand, Max(result) OVER(PARTITION BY brand), year_month
FROM brand;
问题尚不清楚。这是您要找的吗?