Created
December 6, 2011 10:57
-
-
Save mikebaldry/1437786 to your computer and use it in GitHub Desktop.
Query optimisation..
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
| SELECT c.contract_id, csc1.changed_status | |
| FROM contract c | |
| LEFT | |
| JOIN contract_status_change csc1 | |
| ON csc1.contract_status_change_id = | |
| ( SELECT csc2.contract_status_change_id | |
| FROM contract_status_change csc2 | |
| WHERE csc2.contract_id = c.contract_id | |
| ORDER | |
| BY csc2.date_changed DESC | |
| LIMIT 1 | |
| ) | |
| ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment