I know how to do the following using VBA, but I've been asked if I can create a query to achieve the same results. In case one of the resident geniuses here has any ideas, I thought I'd ask.
I have a table containing a number of cases, each having a unique ID.
Some cases are stand-alone, others have "Parent" or "Child" cases, some can have both.
For example
Case 1 - no parent or child cases
Case 2 - no parent or child cases
Case 3 - no parent or child cases
Case 4 - created by Case 3
Case 5 - no parent or child cases
Case 6 - created by Case 4
Case 7 - created by case 6
Case 8 - created by case 6
I want to be able to enter a Case ID and return all relevant case numbers, whether the connected cases are Parents or Children of the entered ID. Ideally, I'd also like to know where in the hierarchy my entered ID falls.
In the above example, if I enter ID 6, I'd want to see something like:
Case 3 - Original
Case 4 - Parent case 3
Case 6 - Parent case 4
Case 7 - Parent case 6
case 8 - Parent case 6
Can this be done using just SQL and without the use of VBA?
I have a table containing a number of cases, each having a unique ID.
Some cases are stand-alone, others have "Parent" or "Child" cases, some can have both.
For example
Case 1 - no parent or child cases
Case 2 - no parent or child cases
Case 3 - no parent or child cases
Case 4 - created by Case 3
Case 5 - no parent or child cases
Case 6 - created by Case 4
Case 7 - created by case 6
Case 8 - created by case 6
I want to be able to enter a Case ID and return all relevant case numbers, whether the connected cases are Parents or Children of the entered ID. Ideally, I'd also like to know where in the hierarchy my entered ID falls.
In the above example, if I enter ID 6, I'd want to see something like:
Case 3 - Original
Case 4 - Parent case 3
Case 6 - Parent case 4
Case 7 - Parent case 6
case 8 - Parent case 6
Can this be done using just SQL and without the use of VBA?