This might be one of those ‘is it worth trying to do?” questions…
I need to write some sql to produce a dataset that really makes no sense – however it is a supplied format that we have no control over (legislative requirement).
Aside from the other 20+ columns of data, we have been asked to provide a summed total of allowance payments for each employee where the total of summed amounts is greater than $1000 for the fiscal year to date. The allowance payments are possibly made up by payments against 15+ allowance codes. This part is fine. However, in the next column, they need a char string of all of the allowance codes used in the summed total (i.e. non zero amounts) for that employee. So there could be 15 codes or 2 or 0…
Can anyone give me some pointers on how to build this text string (if possible).
Very basic Sample set
ID ERN_CD AMT
1 105 200.00
1 ABC 190.00
1 A34 700.00
2 105 300.00
3 105 250.00
3 A34 500.00
3 A35 500.00
3 C99 10.00
Results Required
ID ALLOW_PAID CHAR_STRING
1 1090.00 105~ABC~A34
2 0.00
3 1260.00 105~A34~A35~C99
While this looks more suited to a program rather than straight sql, would be interested to see any approaches to solving this.
Thanks in advance
I need to write some sql to produce a dataset that really makes no sense – however it is a supplied format that we have no control over (legislative requirement).
Aside from the other 20+ columns of data, we have been asked to provide a summed total of allowance payments for each employee where the total of summed amounts is greater than $1000 for the fiscal year to date. The allowance payments are possibly made up by payments against 15+ allowance codes. This part is fine. However, in the next column, they need a char string of all of the allowance codes used in the summed total (i.e. non zero amounts) for that employee. So there could be 15 codes or 2 or 0…
Can anyone give me some pointers on how to build this text string (if possible).
Very basic Sample set
ID ERN_CD AMT
1 105 200.00
1 ABC 190.00
1 A34 700.00
2 105 300.00
3 105 250.00
3 A34 500.00
3 A35 500.00
3 C99 10.00
Results Required
ID ALLOW_PAID CHAR_STRING
1 1090.00 105~ABC~A34
2 0.00
3 1260.00 105~A34~A35~C99
While this looks more suited to a program rather than straight sql, would be interested to see any approaches to solving this.
Thanks in advance