### How many objects cross both Jupiter and Saturn?

This query was suggested by the LSST Science Collaboration (Solar System)

-LJ I think we should be able to support this ... (depends a little bit on how precise the "cross Jupiter and Saturn" is meant to be - if I had originated this query I would probably have a specific r=5.2 AU and r=9.6 AU in mind as meaning 'cross Jupiter's orbit' and 'cross Saturn's orbit', but given that each orbit is slightly eccentric this might not be quite precise enough for some). At some time we may be able to answer this query by actually doing an orbital integration to see if the objects cross the orbits of Jupiter and Saturn, but currently we cannot.

At the moment, the best we can do is an approximation where this can be translated to : how many objects have orbits which cross some inner and outer radius? (where here the inner = semimajor axis of Jupiter, and outer=semi-major axis of Saturn).

```SELECT COUNT(movingObjectId)
FROM MovingObject
WHERE q < 5.2             -- perihelion distance
AND q*(1+e)/(1-e) > 9.6 -- aphelion distance
--     note for some objects this may not be well defined (e may be very close to 1)

```

We should consider adding q*(1+e)/(1-e) to MovingObject instead of calculating on the fly. Also, we might consider adding 'a' = q/(1-e) = semimajor axis, which is likely to be queried on very often.