Created
March 20, 2022 23:00
-
-
Save abmathewks/bb0e753dbde4a6e9dc8e2dae35de83b3 to your computer and use it in GitHub Desktop.
This file contains 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 | |
ob.lead_id, | |
DATE(ob.create_date), | |
TIME(ob.create_date), | |
ob.affiliate_id, | |
ob.amount AS 'our_cost', | |
ob.won_ping, | |
ob.lead_type | |
FROM our_bids AS ob | |
INNER JOIN leads AS l ON ob.lead_id = l.id | |
WHERE ob.affiliate_id = 1008 | |
AND lead_type = 'AUTO' | |
AND ob.id >= | |
(SELECT | |
id | |
FROM | |
( | |
SELECT id FROM our_bids | |
WHERE affiliate_id = 1008 AND lead_type = 'AUTO' AND won_ping = 1 | |
ORDER BY id DESC | |
LIMIT 50 | |
) tb1 | |
ORDER BY id ASC | |
LIMIT 1) | |
ORDER BY won_ping DESC, our_cost DESC | |
LIMIT 5000; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment