Hello everyone,
I have a problem I'm trying to solve using SQL to tag a chart of accounts hierarchy file. My COA has several thousand line items and I need to figure a way to tag the account class field to each account in the chart. The problem is I can't figure a way to setup a proper join for this task since the account class is derived based on a range of account numbers. I can't match on a specific account. Here's an example:
CASH Accounts are between 1010 and 1149
ACCTS RECEIVABLE Accounts are between 1150 and 1299
INVENTORY Accounts are between 1300 and 1539
etc.
I extracted a table with just the min and max ranges of the Account Class items which contains 84 records.
However I can't figure out how to create an SQL update statement to search for accounts in the ranges and tag the appropriate account class.
I did create an update statement for Account Type (Assets / Liabilities / Equity / Revenue / Expenses) using a LIKE clause in the WHERE criteria because it was only 5 items and the logic was much simpler....
UPDATE COA
SET AcctType = 'Assets'
WHERE AcctNum LIKE '1*'
Would that be the only way to do this with such a large array? Account Class has 84 records to go through so I would hope to not have to write 84 queries to do that update.
Any help is appreciated.
I have a problem I'm trying to solve using SQL to tag a chart of accounts hierarchy file. My COA has several thousand line items and I need to figure a way to tag the account class field to each account in the chart. The problem is I can't figure a way to setup a proper join for this task since the account class is derived based on a range of account numbers. I can't match on a specific account. Here's an example:
CASH Accounts are between 1010 and 1149
ACCTS RECEIVABLE Accounts are between 1150 and 1299
INVENTORY Accounts are between 1300 and 1539
etc.
I extracted a table with just the min and max ranges of the Account Class items which contains 84 records.
However I can't figure out how to create an SQL update statement to search for accounts in the ranges and tag the appropriate account class.
I did create an update statement for Account Type (Assets / Liabilities / Equity / Revenue / Expenses) using a LIKE clause in the WHERE criteria because it was only 5 items and the logic was much simpler....
UPDATE COA
SET AcctType = 'Assets'
WHERE AcctNum LIKE '1*'
Would that be the only way to do this with such a large array? Account Class has 84 records to go through so I would hope to not have to write 84 queries to do that update.
Any help is appreciated.