We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Need help with SQL query in alteryx

Svav
6 - Meteoroid

Hi I am trying to add sql query in alteryx input. The query is working good in SQL server but throwing error in alteryx. Can some one correct me where I am doing wrong. We recently started using alteryx.Attached the query

 

 

IF OBJECT_ID('tempdb.dbo.#ques_Renewal', 'U') IS NOT NULL DROP TABLE #ques_Renewal;
IF OBJECT_ID('tempdb.dbo.#Curr_Ques_Renewal', 'U') IS NOT NULL DROP TABLE #Curr_Ques_Renewal;
IF OBJECT_ID('tempdb.dbo.#q_Renewal3', 'U') IS NOT NULL DROP TABLE #q_Renewal;

 

SELECT distinct Question__c
into #ques_Renewal
FROM (SELECT se.id
FROM [Salesforce].[dbo].Sales_Exception__c (NOLOCK) se
LEFT JOIN [Salesforce].[dbo].Apttus_Approval__Approval_Request__c (NOLOCK) ar     ON ar.Sales_Exception__c = se.id
LEFT JOIN [Salesforce].[dbo].Opportunity (NOLOCK) o                             ON o.id = se.Opportunity__c
LEFT JOIN [Salesforce].[dbo].Order_Response__c (NOLOCK) r                         ON se.id = r.Sales_Exception__c
LEFT JOIN [Salesforce].[dbo].[USER] (NOLOCK) u                                     ON u.id = se. Area_VP__c
LEFT JOIN [Salesforce].[dbo].[ACCOUNT] (NOLOCK) acc                                ON acc.id = se.Account__c
LEFT JOIN [Salesforce].[dbo].[RecordType] (NOLOCK) rt                            ON rt.id = se.RecordTypeId
LEFT JOIN [Salesforce].[dbo].Apttus_Proposal__Proposal__c (NOLOCK) q            ON se.Quote_Proposal__c = q.id

 

IF OBJECT_ID('tempdb.dbo.#ques_Renewal', 'U') IS NOT NULL DROP TABLE #ques_Renewal;
IF OBJECT_ID('tempdb.dbo.#Curr_Ques_Renewal', 'U') IS NOT NULL DROP TABLE #Curr_Ques_Renewal;
IF OBJECT_ID('tempdb.dbo.#q_Renewal3', 'U') IS NOT NULL DROP TABLE #q_Renewal;    

 

WHERE
ar.Apttus_Approval__StepLabel__c LIKE '%Rev Ops%'
AND se.Sales_Exception_Expiration_Date__c BETWEEN DATEADD(qq, DATEDIFF(qq, 0, GETDATE()) - 1, 0) AND DATEADD(dd, -1, DATEADD(qq, DATEDIFF(qq, 0, GETDATE()), 0))
AND se.Status__c = 'Approved'
AND rt.[Name] = 'Renewal Pricing Exception') se
LEFT JOIN [Salesforce].[dbo].[Script_Answer__c] (NOLOCK) ans on se.id = ans.Sales_Exception__c
LEFT JOIN [Salesforce].[dbo].[Script_Questions__c] (NOLOCK) ques on ans.Question_ID__c = ques.id
ORDER BY Question__c
select current_ques into #Curr_Ques_Renewal from(values('Add Notes to Invoice')
,('Add Notes to Quote PDF')
,('All Other Non-Pricing Request')
,('Any special note for flag flips completeness or any other downstream RevPro items')
,('Are you requesting the use of prior unused credit?')
,('Break out of compliance')
,('Complete order hold required until released by Finance')
,('Discount Pricing Request')
,('Do any special concessions apply')
,('Does a contract asset exist?')
,('Does a contract modification exist?')
,('Does quote include CSS Priority Service?')
,('Does the quote contain a SKU that needs Tech support and/or Priority Sales team approval?')
,('Does this opportunity leverage any active promotions?')
,('Enter Quote ID')
,('Finance Notes')
,('Is a separate quote as part of this deal?')
,('Is this a ‘ramp up’ or growth SaaS subscription model or Unlimited Deployment Period (UDP)?')
,('Large Customer Pricing (LCP) OrgID')
,('Manual Allocation Required (RevOps Determination)')
,('Manual Deferral required')
,('Maximize Quote Validity')
,('Minimum Annual Spend Not Met')
,('Non-Standard Payment Terms for first invoice only')
,('Promo Code?')
,('Require the use of inactive or special SKUs')
,('Roadmap Requested or Provided')
,('Special Instructions for CSS Priority Service Delivery')
,('Waive 1 year renewal reinstatement requirement')
,('Waive Reinstatement/Recovery/Late Fees')) A(current_ques)
select qr.Question__c
,cqr.current_ques,case when CQR.current_ques is null then QR.Question__c
end as to_be_added_Current_Ques_c,
case when QR.Question__c is null then CQR.current_ques
end as to_be_deleted_current_ques
from #ques_renewal (NOLOCK) qr
full join #Curr_Ques_Renewal(NOLOCK) cqr on qr.Question__c= cqr.current_ques;

1 REPLY 1
apathetichell
20 - Arcturus

Hi - this is a lot of detail on the query but honestly it's not very helpful in terms of turning this into either a query in Alteryx or a workflow in Alteryx. Information like what you are trying to do, errors you are encountering in, and overall platforms you are working with (database backends) would be a good start.

Labels
Top Solution Authors