Friday, December 28, 2018

Retrieve all support cases associated with a Customer including those at project levels using ODBC

There are instances when cases are assigned at a project level. When attempting to pull all cases per Customer, those assigned at the project level are not included. The reason for this is that the customer and the project record associated with the customer have different customer ids.

 

Customer ABC
Customer_id: 2100

Customer ABC:Project123
Customer_id: 21101

Note that these projects will have the associated customer as its parent_id:

Following is an alternate solution.  The result will include the cases filed under the Customer's projects.

SELECT * FROM support_incidents
WHERE company_id IN (SELECT customer_id FROM CUSTOMERS
       WHERE customer_id = '2100'
       OR parent_id = '2100')

No comments:

Post a Comment