Created
January 9, 2015 18:51
-
-
Save rafaeljesus/f782e8b47d35b9eddb64 to your computer and use it in GitHub Desktop.
Over SQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * repair_notification has_many quotations | |
| * ------------- | |
| * | quotation | | |
| * _______________________ | |
| * | id | notification_id | | |
| */ | |
| select * from | |
| (select priority, notification_id, row_number() over(partition by notification_id order by quotation_date desc, createddate desc) seq from erm_quotation ) q | |
| where q.seq = 1; -- return the first result, q.seq = 2 return the second result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment