Created
December 5, 2018 18:15
-
-
Save JDHatman/bd3b2d9d7f373e109ccb5e4d7b8b0291 to your computer and use it in GitHub Desktop.
ifw_query
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 concat(phonenumber.name, ' ', processed.calldatetime) as NewID, processed.phonenumber, processed.calldatetime, processed.originalcalledpartynumber, processed.secondextension, processed.callingpartynumber, phonenumber.name, count(case processed.originalcalledpartynumber when '8271' then 1 else null end) over (partition by phonenumber.name) as total, case when processed.smdrtype = 'A' then 'True' else 'False' end as Abandoned from processed | |
right join phonenumber on processed.phonenumber = RIGHT(phonenumber.phonenumber, LEN(phonenumber.phonenumber) - 1) | |
where convert(date, calldatetime) = convert(date, getdate()) and originalcalledpartynumber = '8271' | |
UNION | |
select concat(phonenumber.name, ' ', processed.calldatetime) as NewID, processed.phonenumber, processed.calldatetime as CallDate, processed.originalcalledpartynumber, processed.secondextension, processed.callingpartynumber, phonenumber.name, count(case processed.originalcalledpartynumber when '8271' then 1 else null end) over (partition by phonenumber.name) as total, case when processed.smdrtype = 'A' then 'True' else 'False' end as Abandoned from processed | |
right join phonenumber on right(processed.originalcalledpartynumber, len(processed.originalcalledpartynumber) - 2) = RIGHT(phonenumber.phonenumber, LEN(phonenumber.phonenumber) - 1) | |
where convert(date, calldatetime) = convert(date, getdate()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment