You need to LIMIT the data you return by the percentiles of the rows returned in the result set.
Try the following:
SELECT TrackingID, OpenTime, FirstPoint
FROM PointsTable
ORDER BY FirstPointGMT - OpenTimeGMT
LIMIT (13*((SELECT COUNT(*) FROM PointsTable) +1) / 100),
((SELECT COUNT(*) FROM PointsTable)
-
(26*((SELECT COUNT(*) FROM PointsTable) +1) / 100)
)
Explanation above
The only tricky thing here is the Limit clause and its syntax:
> LIMIT start_row,number_of_rows_to_return
Our start_row should be the first element after the first record 13 / 100th (13% of the way) in the result set. To do this, we use this formula:
rownumber_or_number_of_rows_in_resultset_Npercent_in =
( Npercent * ( number_of_rows_in_resultset + 1) / 100)
which is equal (13*((SELECT COUNT(*) FROM PointsTable) +1) / 100)
.
Our number_of_rows_to_return should be the total number of lines, minus 26% of the lines (13% of the bottom and 13% of the top) or
(total_number_of_rows - number_of_rows_26percent_of_the_way_in)
, :
( (SELECT COUNT(*) FROM PointsTable)
-
(26*((SELECT COUNT(*) FROM PointsTable) +1) / 100)
)
EDIT: Niyaz , :
SELECT TrackingID, OpenTime, FirstPoint
FROM PointsTable
ORDER BY FirstPointGMT - OpenTimeGMT
LIMIT (13*((SELECT COUNT(*) FROM PointsTable) +1) / 100),
(74*((SELECT COUNT(*) FROM PointsTable) +1) / 100)
, . , 13% 74% .