SELECT t1.timestamp, t1.field_tag AS new_column,
CASE
WHEN t1.field_tag = t2.field_tag THEN 'No change'
ELSE 'Change response. New value: ' || t1.field_tag || '. Old value: ' || t2.field_tag
END AS change_response
FROM your_table t1
LEFT JOIN your_table t2 ON t1.timestamp > t2.timestamp AND t1.field_tag <> t2.field_tag
GROUP BY t1.timestamp, t1.field_tag, t2.field_tag
ORDER BY t1.timestamp DESC;
1条答案
按热度按时间lmvvr0a81#