SQL Server 2012
I have a simple table that has a Nullable (int) Position and a (datetime) Created field.
I would like to do a select * from this table order by created desc but ...if a record has a Position value NOT NULL, we should insert that record into that specific position on the result set ...
Looking at the SQlFiddle ...the expected result of my query should be: "one", "two", "three", "four". "five", "six"
Note: record "four" has position value 9 and that means that if the result set would be returning 15 records, it will be on position 9.
In the case of two records with same position (ie. 9) the one with older date takes precedence.