select distinct on (revf3) f1, f2, f3, revers(f3) as revf3 from table order by revf3
Is there a way to return just f1, f2, f3 in my results and forget revf3 (so it doesn't show in results)?
Thanks.
On Fri, Dec 21, 2012 at 9:57 AM, Seth Gordon <sethg@ropine.com> wrote:
If you only want one value per id, then your query should be “SELECT DISTINCT ON (id) ...”
If you care about which particular value is returned for each ID, then you have to sort the results: e.g., if you want the minimum value per id, your query should be “SELECT DISTINCT ON (id) ... ORDER BY value”. The database will sort the query results before running them through the DISTINCT filter.
How do I just choose a preferred element say value 'a' over any other elements returned, that is the value returned is from a subquery to a larger query?