Skip to content

Instantly share code, notes, and snippets.

@drogus
Created February 15, 2009 08:01
Show Gist options
  • Save drogus/64643 to your computer and use it in GitHub Desktop.
Save drogus/64643 to your computer and use it in GitHub Desktop.
sql_attr_multi = uint feature_ids from query; \
SELECT DISTINCT ON (feature_options.feature_id) restaurants.id, feature_options.id \
FROM feature_options \
INNER JOIN restaurant_feature_options ON feature_options.id = restaurant_feature_options.feature_option_id \
INNER JOIN restaurants ON restaurants.id = restaurant_feature_options.restaurant_id \
INNER JOIN features ON features.id = feature_options.feature_id \
WHERE features.radio = 't' \
ORDER BY feature_options.feature_id ASC, restaurant_feature_options.votes DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment