表格每天保存变量V1的状态:
function hasKey(obj, key) {
return Object.keys(obj).indexOf(key) !== -1
}
我感兴趣的是:变量何时更改其状态,以及新状态是什么?
结果应为:
V1 Status Date
-----------------
X A date_1
Y C date_2
X B date_3
X B date_4
Y D date_5
X B date_6
Y D date_7
X A date_8
答案 0 :(得分:2)
您希望显示那些值与前一行不同的行:
SELECT *
FROM MyTable
WHERE Status IS NOT (SELECT Status
FROM MyTable AS T2
WHERE T2.V1 = MyTable.V1
AND T2.Date < MyTable.Date
ORDER BY T2.Date DESC
LIMIT 1);