Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Select from subquery? #822

Unanswered
tigerk00 asked this question in Q&A
Discussion options

Hello guys! Currently I have a problem with sorting of distinct rows from my table(I want to sort by only one field that is not present in distinct()) and found solution that is written on raw SQL. I am newbie so I don't know how should I do the same construction, but in python-gino:

SELECT * FROM 
 (SELECT DISTINCT ON (address_id) purchases.address_id, purchases.* 
 FROM "purchases" 
 WHERE "purchases"."product_id" = 1 ORDER BY address_id DESC ) 
ORDER BY purchased_at DESC

Thanks in advance

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /