Question: I have a CDS View with multiple associations:

```
define view ZORDER as select from ZORDERHDR as orderHdr
association [0..1] to ZORDER_LOCATION as _location on _location.orderID = orderHdr.orderID
association [0..*] to ZORDER_ITEM as _items on _items.orderID = orderHdr.orderID
association [0..*] to ZORDER_PARTNER as _partners on _partners.orderID = orderHdr.orderID

```

Now, I would like to select from the view a single order and get a result something like this:

```
TYPES: BEGIN OF t_order,
         header TYPE zorderhdr,
         location TYPE zorder_location,
         items TYPE zorder_items, "This is a table type
        END OF t_order.

```

Is there a SELECT statement that can read all the order into a nested structure like the one above?

Edit: I added a second 0..\* association to ensure that the proposed solution doesn't suggest to select everything and then reduce the header and location to their structures. The problem I see is that with complex CDS views I seem to need to handle all the associations with custom code like I would do if it was normal OpenSQL, then I lose the benefit of the CDS views model design (when not consuming from Gateway) and I select too much data.

Answer: 
You need to swap the terms on each side of the comma operator because `big` will be assigned the last one on the list. You also need to add parentheses in order to make it evaluate correctly:

```
big = (v1 > v2) ? (small = v2, v1) : (small = v1, v2);

```

See the explanation [here](https://en.cppreference.com/w/cpp/language/operator_other):

> 
> In a comma expression `E1, E2`, the expression `E1` is evaluated, its
>  result is discarded [...] The type, value, and value category of the result of the comma expression are exactly the type, value, and value category of the second operand, `E2`
> 
> 
> 

---

Also, if you want it to be short and readable, you could consider this instead:

```
std::cin >> big >> small;
if (small > big)
    std::swap(big, small);

```
```
big = v1 > v2 ? v1, small = v2 : v2, small = v1;

```

This doesn't do what you expect.
When using the comma operator `,` to separate a number of expressions, the resulting expression gets the value of the last of those expressions. So in your case, if `v1 > v2`, `big` is assigned the value of:

```
 v1, small = v2

```

which is the value of `small = v2`, which becomes `v2` instead of `v1` as you intended. So you end up assigning both numbers the same value when `v1 > v2`!

You could use separate statements:

```
big = v1 > v2 ? v1 : v2;
small = v1 < v2 ? v1 : v2;

```