sql - Possible to play back table of inserts/deletes to get the current state? -


I have a table that stores the devices as a history of change, for example:

Sample table section history (includes a numeric primary key):

  ID greater data set date (desired result) 1 I partA 1 2014-07-01 2 I get partB 1 2014-07-01 3 I partC 1 2014 -07-01 Parts A, B, C4D Part C 2014-07-03 Parts A, B5I Partged 3 2014-07-06 Parts A, B, Z6 D part 4 2014-07-20 7 D part 4 20 14-07-20 8 Eye Part C 2014-07-20 9 Eye Part 4 2014-07-20 Parts B, C, Q  

In each set, one or more I- (New device) D - Deleted (deleting device) valid data (no meaning to remove non-existent devices etc.)

Is it possible to use this data SQL (not PL / SQL) as if I can get the position of the device on a specific date or set?

For example:

  Select Data, Set, Date From (... Ninja SQL ...) Where Change Date = Date '2014 -07 -03 'Part A2 2014-07-03 Partba 2 2014-07-03 Select Data, Set, Date From (... Ninja SQL ...) Where Set = 4 Part 4 2014-07-20 Part 4 2014-07-20 Part 4 2014-07-20 

If you have parts and a special date " As "most recent calculation, you can do this in SQL with this structure. In fact, increase the number of values ​​"I" and decrease the number of "D" values ​​to get the number. Select data, sum (case when hst = 'I' then 1 when Hst = 'D' then -1 and 0 end) Lt; = DATE '2014-07-03' Data group with zodiac (in case when hst = 'I' then 1 when hst = 'd' then -1 and 0 end)> 0;


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -