Rating times
1 20.09.2016
2 21.09.2016
3 22.09.2016
4 23.09.2016
2 24.09.2016
3 25.09.2016
1 26.09.2016
谢谢,
答案 0 :(得分:1)
SELECT COUNT(1) AS COUNT_OF_TIMES_RATING_GOT_DECREASED
FROM
(
SELECT rating,
times,
rating - LEAD( rating, 1 ) OVER ( ORDER BY times ) AS diff_rating
FROM table
)
WHERE diff_rating > 0;
答案 1 :(得分:0)
没有这些功能可用,例如使用DB2 for i,以下内容应该足够[轻松省略 fluff 我添加以生成漂亮的报告,和/或可选地纠正我的包含row_number以显示from / to而不是显示表示减少过渡的“times”值]:
Time.now.strftime('%d-%b-%y') # => "28-Sep-16"
Time.now.strftime('%d-%b-%Y') # => "28-Sep-2016"