I have two tables: 1) current iOS versions and 2) target iOS version and wanted to get a target iOS version for each version, how should I go about doing this?
| iOS Version |
| ------------ |
| 11.0.0 |
| 12.0.1 |
| 13.5.0 |
| 16.4.1 |
| 17.1.0 |
Target iOS Version |
---|
12.5.7 |
15.8.0 |
17.2.0 |
Goal: The goal was for each current version to have a target version to be matched with, i.e. if the current version is 12.0.1, the target version would be 12.5.7 but if the current version exceeds 12.5.7, for example 13.5.0 then the target version would be 15.8.0 but not the latest 17.2.0.
| iOS Version | Target iOS Version |
| ------------ | ------------ |
| 11.0.0 | 12.5.7 |
| 12.0.1 | 12.5.7 |
| 13.5.0 | 15.8.0 |
| 16.4.1 | 17.2.0 |
| 17.1.0 | 17.2.0 |
2条答案
按热度按时间ikfrs5lh1#
A correlated subquery in the select list is probably the most basic solution:
7xzttuei2#
One method is a
cartesian join
and getting the min(t.version) greater than each version.