Created
March 5, 2018 06:33
-
-
Save fodra/7edb29f28b63c797c79d43391cb47714 to your computer and use it in GitHub Desktop.
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
| -- get the 10 most recent sold listings for the specific agency | |
| SELECT id, status, sold_price, sold_date | |
| FROM listings_listing | |
| WHERE agency_id = '3ab9adc2-7fd2-4b24-8cd0-d0cc69270fbf' AND status = 'S' | |
| ORDER BY sold_date DESC LIMIT 10; | |
| -- modify the query set to a new date somewhere between now and four weeks ago | |
| UPDATE listings_listing | |
| SET sold_date = now(), | |
| source_type = 'M' | |
| FROM ( SELECT id, status, sold_price, sold_date | |
| FROM listings_listing | |
| WHERE agency_id = '3ab9adc2-7fd2-4b24-8cd0-d0cc69270fbf' AND status = 'S' | |
| ORDER BY sold_date DESC LIMIT 10) as subquery | |
| WHERE listings_listing.id = subquery.id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment