Created
August 23, 2017 22:55
-
-
Save guiassemany/df55509ab70ebee2e7fe8ef3fc008f02 to your computer and use it in GitHub Desktop.
SQL Key Value to Row
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 | |
l.status, | |
l.date_created, | |
ca1.value AS Email, | |
ca2.value AS Name, | |
ca3.value AS Phone | |
FROM tablename l | |
LEFT JOIN lead_data AS ca1 ON l.id = ca1.id_lead AND ca1.key='email' | |
LEFT JOIN lead_data AS ca2 ON l.id = ca2.id_lead AND ca2.key='name' | |
LEFT JOIN lead_data AS ca3 ON l.id = ca3.id_lead AND ca3.key='phone' | |
WHERE (l.id_campaign = '17') AND l.status = 'nova' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment