Database: Select last non-null entries

前端 未结 4 1086
你的背包
你的背包 2021-02-19 11:47

Here\'s a question I\'ve been racking my brain over. Let\'s say I have a table that has a series of timestamps and a part number as the primary key. The table stores incremental

4条回答
  •  野的像风
    2021-02-19 12:12

    ruakh is right. Alternative: Write a user-defined aggregate using SQL-CLR. This aggregate can run bottom-top-top over your rows and remember the first non-null value of each column.

    You can also do this in the application. Make your program request rows in sorted order in batches of, say, 10 rows. Aggregate these batches like described above. If after the current batch is done a null-column is there get the next batch.

提交回复
热议问题