How to retrieve required data only when sorted on multiple Order by? [closed]

asked 2014-05-07 17:00:21 +0200

Andy_new gravatar image

I'm new to BASE and SQL. I have a table with fields for Group, Strategy, Profit, Success_Ratio. Each strategy is unique and a member of a group, there are 10 groups in total, but in excess of a 1000 strategies. Each Strategy has a level of profit achieved and a Success Ratio (which is calculated in a separate programme)

Within each group I want to know which strategy has the highest Success_Ratio, and just return these 10 results for the query.

Using ORDER_BY and LIMIT has enabled me to sort by Group and then by success Ratio but the LIMIT is applied to the first records returned which are all in the same Group. Is there a way of generating a query which will only find the top performing strategy from each group possibly by using a nested search or some other technique completely?

Many thanks

Andy

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by Alex Kemp
close date 2016-02-21 21:12:37.684900

Comments

A bit difficult to conceptualise your data structure, and additionally when you write "just return these 10 results" from the query - which 10 results ? The top 10 success ratio values for eahc group, or each strategy ? Your question would probably be better asked on a SQL specific mailing list / discussion forum.

Alex Thurgood gravatar imageAlex Thurgood ( 2014-08-11 10:45:56 +0200 )edit