For fetching all preceding siblings, use the preceding-siblings
axis and select all siblings before the last matching <pricing/>
tag.
SELECT Statuses = Statuses.query('
/history/pricing[
@updatedAt <= sql:variable("@date") and last()
]/preceding-sibling::pricing')
By the way, while your example data has <status/>
tags, your query expects <pricing/>
tags?
I forgot MS SQL Server doesn't support that axis, but it supports the node order operator <<
which you can use to work around that. This query says "select all pricing nodes which occur before the last pricing node with this value".
/history/pricing[. << (/history/pricing[@updatedAt <= "2012-30-10"])[last()]]
Have a try on SQL Fiddle.