SELECT
DATEDIFF(day, Bookings.ArrivalDate, Bookings.DepartureDate) AS AmountDays,
PitchValues.Value,
(DATEDIFF(day, Bookings.ArrivalDate, Bookings.DepartureDate)) * PitchValues.Value AS YourCol
FROM
Bookings INNER JOIN
PitchValues ON Bookings.PitchType_Skey = PitchValues.PitchType_Skey
または、見栄えを良くするためだけに:
SELECT
P0.AmountDays,
P0.Value,
(P0.AmountDays * P0.Value) as YourCol
FROM
(
SELECT
DATEDIFF(day, Bookings.ArrivalDate, Bookings.DepartureDate) AS AmountDays,
PitchValues.Value
FROM
Bookings INNER JOIN
PitchValues ON Bookings.PitchType_Skey = PitchValues.PitchType_Skey
) P0
nullがある場合は、列の周囲でISNULL(、0)を実行することもできます。これにより、値全体がnullになります。そのようです:
SELECT
P0.AmountDays,
P0.Value,
(P0.AmountDays * P0.Value) as YourCol
FROM
(
SELECT
ISNULL(DATEDIFF(day, Bookings.ArrivalDate, Bookings.DepartureDate), 0) AS AmountDays,
ISNULL(PitchValues.Value, 0) as Value
FROM
Bookings INNER JOIN
PitchValues ON Bookings.PitchType_Skey = PitchValues.PitchType_Skey
) P0