Question: When a new Project is created in DevOps organization, how Project administrators is assigned to that Project. At the time of creation, there is no input parameter to specify administrators.

How to assign a DevOps group as Project administrators using automation.

Answer: 
TLDR: **No, you must keep using a loop structure.**

I've been there. The joining on "closest day" makes it hard to use a nice set operation. Here's why. Consider those records that have the same equijoin properties (vendor=item etc):

```
Supply: Day 1
Supply: Day 2
Demand: Day 2

```

In this case, you will probably want to join Supply Day 2 with Demand Day 2 due to time difference. But if it was instead:

```
Supply: Day 1 
Supply: Day 2 
Demand: Day 2 
Demand: Day 3

```

You'd probably want Supply Day 1 - Demand Day 2 and Supply Day 2 - Demand Day 3.

This means that each line depends on other lines in a non-easy way (ie: lag/lead window functions won't save you).

This is one of the rare cases you need a cursor/while.
SQL works best on set oriented approach and yes it is possible to have a set oriented approach to solve problems like this. Set oriented approach will be more efficient than a looping logic, in almost all cases. Do you have huge volume of bidders and sellers and you are keen on matching them as quickly if yes -> SQL is very good approach here. Are you worried concurrent users flooding the demand and supply tables data and you wish to get your processing through as soon as it comes, SQL approach would be good option.

On another hand, do you envision your rules for matching sellers and buyers to change frequently. Eg: will additional criteria (say two buyers going to bid for same qty and price at about the same time, and one has a higher credit\_score than other). Would there be brokers-fee to be considered then matching after your have set up the processing logic. Can there be overriding conditions to a perfectly matched buy and sell order to be made use of. If so, from a maintenance perspective it might be easier to have this kind of processing on rows and looping logic.

As said above, share the actual tables and expected results and will be able formalize the query neeed.