Pls help - Limiting query results by percentage of results
Pls help - Limiting query results by percentage of results
От:
"Brian G. Huber" <brianghuber@yahoo.com>
Дата:
Hello all -
I am trying to limit the results of a query using the LIMIT clause - but instead of an absolute number I would like to limit by a percentage of rows returned.
It seems the LIMIT clause only supports absolute numbers. Any ideas greatly appreciated.
TIA,
BGH
PS - The analogous syntax in Access is "SELECT TOP n PERCENT" which returns the top n percent of rows ordered by ORDER BY.
Re: Pls help - Limiting query results by percentage of results
От:
Josh Berkus <josh@agliodbs.com>
Дата:
Brian, > I am trying to limit the results of a query using the LIMIT clause - but instead of an absolute number I would like to limit by a percentage of rows returned. We don't have that feature, I'm afraid. You'd have to write a procedure or subroutine which calculated that number an then passed it to LIMIT. -- -Josh Berkus Aglio Database Solutions San Francisco
Re: Pls help - Limiting query results by percentage of results
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Josh Berkus writes: >> I am trying to limit the results of a query using the LIMIT clause - but >> instead of an absolute number I would like to limit by a percentage of rows >> returned. > We don't have that feature, I'm afraid. You'd have to write a procedure or > subroutine which calculated that number an then passed it to LIMIT. This sounds like a proxy for wanting to know the total number of rows returned by the query, in advance of executing it. But the backend has no better idea than you do how many will be returned :-( regards, tom lane