Created
March 16, 2013 15:05
-
-
Save metametaclass/5176764 to your computer and use it in GitHub Desktop.
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
| with recursive FullAccounts as | |
| (select 0 ACCNT_XMLOBJ_ID, null ACCNT_PARENT_ID, null ACCNT_NUM, null ACCNT_Group from RDB$DATABASE | |
| union | |
| select ACCNT_XMLOBJ_ID, ACCNT_PARENT_ID, ACCNT_NUM, ACCNT_Group from Accounts | |
| ), | |
| AccountParents as | |
| (select ACCNT_XMLOBJ_ID CHILD_ID, ACCNT_XMLOBJ_ID, ACCNT_PARENT_ID, ACCNT_NUM, ACCNT_Group from FullAccounts | |
| union all | |
| select AH.CHILD_ID CHILD_ID, ACCNT_XMLOBJ_ID, ACCNT_PARENT_ID, ACCNT_NUM, ACCNT_Group from FullAccounts | |
| join AccountParents ah on ACCNT_XMLOBJ_ID=ah.ACCNT_PARENT_ID | |
| ) | |
| select distinct CHILD_ID,ACCNT_XMLOBJ_ID, ACCNT_PARENT_ID from AccountParents | |
| order by 1,2,3 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment