sixtoedsloth
IS-IT--Management
Hi, i hope this isnt to much to ask!
I have a database that has tables : -
batch
batchLines
buyers
commissionSpec
I need to give a date range and return all the batch records that are between the dates, joined with the batchLines for each batch.
so far so easy!
then for each batch there is a status flag, if this is 'M' then i need to multiply the count of batchLines for that batch by the value of buyers.commission and store the result in batch.commission
OR
if batch.status = 'P' i need to cycle through all the batchlines and check if the batchLine.grade is 'IN' a field
containing valid grades that resides in commissionspec which has a PK which is the FK in batches and store that in batch.commission
batch.buyer = '02'
batch.status = 'P'
batchline.grade = '3L'
commisionspec.buyer = '02'
and the commisionspec.spec = '3L4L3H4H'
then produce a buyers commision report
I suppose the question is this ;
is this going to be viable in pure sql, or should i use VB to do the processing into some temp tables and then report on them?
the backend database is powerflex, and im using the connx odbc driver to access the data.
I appreciate / assume this is a tricky request, and the customer wont let me post data here for 'confidentiality reasons' so i would value your opinions!
Cheers
Six
I have a database that has tables : -
batch
batchLines
buyers
commissionSpec
I need to give a date range and return all the batch records that are between the dates, joined with the batchLines for each batch.
so far so easy!
then for each batch there is a status flag, if this is 'M' then i need to multiply the count of batchLines for that batch by the value of buyers.commission and store the result in batch.commission
OR
if batch.status = 'P' i need to cycle through all the batchlines and check if the batchLine.grade is 'IN' a field
containing valid grades that resides in commissionspec which has a PK which is the FK in batches and store that in batch.commission
batch.buyer = '02'
batch.status = 'P'
batchline.grade = '3L'
commisionspec.buyer = '02'
and the commisionspec.spec = '3L4L3H4H'
then produce a buyers commision report
I suppose the question is this ;
is this going to be viable in pure sql, or should i use VB to do the processing into some temp tables and then report on them?
the backend database is powerflex, and im using the connx odbc driver to access the data.
I appreciate / assume this is a tricky request, and the customer wont let me post data here for 'confidentiality reasons' so i would value your opinions!
Cheers
Six