Last week I came up with this option. I haven't made performace tests. Maybe you could help me with that.
DECLARE @test-2TABLE(
myintint)
INSERT INTO @test-2 VALUES(1),(2),(3),(4),(5),(6),(7),(8),(9);
WITH CTE AS(
SELECT myint,
NTILE( 2) OVER( ORDER BY myint) tile
FROM @test-2
)
SELECT CASE WHEN SUM( CASE WHEN tile = 1 THEN 1 END) = SUM( CASE WHEN tile = 2 THEN 1 END)
THEN (MAX( CASE WHEN tile = 1 THEN myint END) + MIN( CASE WHEN tile = 2 THEN myint END))/2.0
ELSE MAX( CASE WHEN tile = 1 THEN myint END) END
FROM CTE