Pada dasarnya perlakukan kedua kueri tersebut sebagai sub kueri seperti di bawah ini.
select x.number / y.number
from
(
SELECT COUNT(cvu.[ID]) as number, 'Exp' AS [Exp]
FROM [dbo].[tblClientVehicleUnit] cvu
WHERE ExpirationDate < GetDate()
AND cvu.Id = '4C1'
) x
join
(
SELECT COUNT(cvu.[ID]) as number, 'NonExp' AS [Exp]
FROM [dbo].[tblClientVehicleUnit] cvu
WHERE ExpirationDate > GetDate()
AND cvu.Id = '4C1'
) y on 1=1
Jika Anda ingin melangkah lebih jauh, Anda dapat menjadikan cvu.id sebagai bagian dari pilih dan ubah gabungan sehingga Anda dapat melakukannya di semua
cvu.idselect x.id, x.number / y.number
from
(
SELECT cvu.id, COUNT(cvu.[ID]) as number, 'Exp' AS [Exp]
FROM [dbo].[tblClientVehicleUnit] cvu
WHERE ExpirationDate < GetDate()
group by cvu.Id
) x
join
(
SELECT cvu.id, COUNT(cvu.[ID]) as number, 'NonExp' AS [Exp]
FROM [dbo].[tblClientVehicleUnit] cvu
WHERE ExpirationDate > GetDate()
group by cvu.Id
)y on x.id = y.id