简体   繁体   中英

How to track differences on each rows in sql

I have this audit table and want to add a hardcoded status report on my view. Record number is dynamic depending on how many changes has been made. I'm thinking if this is possible in case switch to manipulate data? Or do I need to use a loop?

DBAction    DateFrom    Dateto  Status
Update  12/15/2020  12/25/2021  Date To has been updated
Update  12/15/2020  12/15/2021  Date From has been updated
Insert  12/13/2020  12/15/2021  New

Thank you for your time.

Using Lag/Lead sql function will cater the work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM