Hi,
Postgres only accepts contants in limit clause. So the solution above does not work.
Your select is something like this:
SELECT *
FROM (SELECT T.HEIGHT,
-- this tells us the "ranking" of each row
-- by counting all the heights that are small than
-- height in the that row
(SELECT COUNT(*) + 1
FROM <table> T1
WHERE T1.HEIGHT < T.HEIGHT
) AS RANK,
-- this tells us the count of rows in the table
(SELECT COUNT(*)
FROM <table> T1
) AS REC_COUNT
FROM <table> T
ORDER BY T.HEIGHT
) T
-- now just list rows wich ranking is between (not top30) and (not bottom30)
WHERE T.RANK BETWEEN (T.REC_COUNT*0.30) AND (T.REC_COUNT*0.70)
This is gonna work in any database what accepts subselects (subqueries).
This does not treat equalties in "heights", but it could be done using primary key
SELECT COUNT(*) + 1
FROM <table> T1
WHERE (T1.HEIGHT < T.HEIGHT)
OR (T1.HEIGHT = T.HEIGHT and T1.PK_FIELD < T.PK_FIELD)
Regards.