Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
Estela's answer provides great insight about how to do it also in SQL Server. Unfortunately, there does not seem to be a build-in array functionality, so one way is to rely on strings as shown here...
Answer
#6: Post edited
- Estela's answer provides great insight about how to do it also in SQL Server. Unfortunately, there does not seem to be a build-in array functionality, so one way is to rely on strings as shown [here](https://dba.stackexchange.com/q/162298).
- Basically, instead of accumulating values in an array, a string does this (way less efficiently for many records, I would say).
In this case, a query that seems to provide the results you are looking for is the following:- **Note:** considering how complex things might get (edge cases might add up to the logic), this type of query might be better be done in a language/framework like C++, Java or .NET, unless there is a very strong reason to remain in SQL. These allow for much more flexibility, considering the iterative nature of the algorithm (not so suitable for set based operations) and also provide way better-debugging capabilities.
- Estela's answer provides great insight about how to do it also in SQL Server. Unfortunately, there does not seem to be a build-in array functionality, so one way is to rely on strings as shown [here](https://dba.stackexchange.com/q/162298).
- Basically, instead of accumulating values in an array, a string does this (way less efficiently for many records, I would say).
- In this case, a query that seems to provide the results you are looking for is the following (some security check does not allow to post the query, so I am using SQL fiddle for sharing it):
- http://sqlfiddle.com/#!18/a50101/1
- **Note:** considering how complex things might get (edge cases might add up to the logic), this type of query might be better be done in a language/framework like C++, Java or .NET, unless there is a very strong reason to remain in SQL. These allow for much more flexibility, considering the iterative nature of the algorithm (not so suitable for set based operations) and also provide way better-debugging capabilities.
#5: Post edited
- Estela's answer provides great insight about how to do it also in SQL Server. Unfortunately, there does not seem to be a build-in array functionality, so one way is to rely on strings as shown [here](https://dba.stackexchange.com/q/162298).
- Basically, instead of accumulating values in an array, a string does this (way less efficiently for many records, I would say).
In this case, a query that seems to provide the results you are looking for is the following:
- Estela's answer provides great insight about how to do it also in SQL Server. Unfortunately, there does not seem to be a build-in array functionality, so one way is to rely on strings as shown [here](https://dba.stackexchange.com/q/162298).
- Basically, instead of accumulating values in an array, a string does this (way less efficiently for many records, I would say).
- In this case, a query that seems to provide the results you are looking for is the following:
- **Note:** considering how complex things might get (edge cases might add up to the logic), this type of query might be better be done in a language/framework like C++, Java or .NET, unless there is a very strong reason to remain in SQL. These allow for much more flexibility, considering the iterative nature of the algorithm (not so suitable for set based operations) and also provide way better-debugging capabilities.
#3: Post edited
Estela's answer provides great insight about how to do it also in SQL Server. Unfortunately, there does not seem to be a build-in array functionality, so one way is to rely on strings as shown [here](https://dba.stackexchange.com/q/162298).
- Estela's answer provides great insight about how to do it also in SQL Server. Unfortunately, there does not seem to be a build-in array functionality, so one way is to rely on strings as shown [here](https://dba.stackexchange.com/q/162298).
- Basically, instead of accumulating values in an array, a string does this (way less efficiently for many records, I would say).
- In this case, a query that seems to provide the results you are looking for is the following: