Question: I have a table with services containing columns ACT\_MONTH (activation month) and S\_TYPE (service type). I need SQL query that will return a table showing ALL MONTHS and ALL TYPE table combinations with corresponding number of services activated in that month. The problem is when there's no service in some month/type but I need them in this table as zeros. Simple GROUP BY does not show these zero groups.

So the resulting table should look like:

```
ACT_MONTH | S_TYPE | QTY
==========+========+=====
2022M01   | A      |  20
2022M01   | B      |  33
2022M02   | A      |   6
2022M02   | B      |   0
2022M03   | A      |  12
2022M03   | B      |   4
2022M04   | A      |   0
2022M04   | B      |   0
2022M05   | A      |   0
2022M05   | B      |   0
...
2022M12   | A      |   0
2022M12   | B      |   0

```

Answer: 
There are several options here.

The first option I had was to reduce how far ahead the turtle looks. Only the cars that fall at most half of the world length ahead of the car are considered to be ahead. Oh course this might mean there is not always a car that can be considered the closest car in front, so it might not be sufficient depending on what exactly you need.

```
  ask turtles with [color = red] [
    let half-size (max-pxcor - min-pxcor) / 2
    set car-in-front min-one-of other turtles in-cone half-size 0 [distance myself]
    ask car-in-front [set color yellow]
  ]

```

The next version instead insures that there is always a car infront of the focal car. I removed the in-cone for this specific example because in the basic traffic model, every single other turtle is in the cone that you specified. First of, I use `(xcor - [xcor] of myself)` checks for each other turtle how far in front of the focal turtle thay are. This gives you some problems with world wrapping. That is why I added the second part `(xcor - [xcor] of myself) mod (max-pxcor - min-pxcor)`. The modulus of the total world length ensures that if the result of `(xcor - [xcor] of myself)` is a negative number, it is substracted from the world length with a positive number as result.

```
  ask turtles with [color = red] [
    set car-in-front min-one-of other turtles [(xcor - [xcor] of myself) mod (max-pxcor - min-pxcor) ]
    ask car-in-front [set color yellow]
  ]

```
That's what the zero in "in-cone 50 0" accomplishes. See the dictionary.

> 
> **in-cone distance angle**
> 
> 
> This reporter lets you give a turtle a "cone of vision" **in front of
> itself**. The cone is defined by the two inputs, the vision distance
> (radius) and the viewing angle. The viewing angle may range from 0 to
> 360 and is centered around the turtle's current heading.
> 
> 
>