New to SQL and need some assistance.
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:
| 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 |
>Solution :
A correlated subquery in the select list is probably the most basic solution:
select c.[iOS Version],
(select min([Target iOS Version]) from targetosversionstable
where [Target iOS Version] > c.[iOS Version]) as [Target iOS Version]
from currentosversionstable c