Keeping DB Table sorted using multi-field formula (Microsoft SQL)

Posted by user298167 on Stack Overflow See other posts from Stack Overflow or by user298167
Published on 2010-03-20T21:08:38Z Indexed on 2010/03/20 21:11 UTC
Read the original article Hit count: 264

Filed under:
|
|
|
|

Hello Everybody. I have a Job Table which has two interesting columns: Creation Date and Importance (high - 3, medium 2, low - 1). Job's priority calculated like this: Priority = Importance * (time passed since creation). The problem is, Every time I would like to pick 200 jobs with highest priority, I dont want to resort the table. Is there a way to keep rows sorted?

I was also thinking about having three tables one for High, Medium and Low and then sort those by Creation Date.

Thanks

© Stack Overflow or respective owner

Related posts about Microsoft

Related posts about sql