Grouping similarly weighted animals
You're given the following table showing the weights (in pounds) of various animals:
Write a SQL query that evaluates each animal in our list and returns all animals within the same list that are within 10% of the evaluating animal's weight. For example, if we're evaluating the humpback whale, we would want to aggregate a list of animals that are between 27,000 and 33,000 pounds. Given the partial table above, our query should return:
|Humpback whale||Grey whale|
|Gray whale||Humpback whale|
You can view/query the table in an interactive SQL fiddle here.
Subscribe to premium account to see the solution.Get premium now