我正在尝试验证示例,如果日期为空,请从另一个字段中选择一个日期。在查询下方:
SELECT
*
FROM
OrderPublish OP
INNER JOIN Advertising AD ON
AD.IdOrderPublish = OP.IdOrderPublish
INNER JOIN Client Cli ON
Cli.IdClient = OP.IdClient
LEFT JOIN AdvertisingInserted AII ON
AD.IdAdvertisingInserted = AII.IdAdvertisingInserted
LEFT JOIN TypeProduct TP ON
AII.IdTypeProduct = TP.IdTypeProduct
INNER JOIN Publication PUB ON
PUB.IdAdvertisingInserted = AII.IdAdvertisingInserted
WHERE
TP.IdTypeProduct in (5,7)
AND CASE WHEN PUB.DtIni IS NULL
THEN
OP.DtInc >= Isnull('08/18/2013', OP.DtInc)
ELSE
PUB.DtIni >= Isnull('08/18/2013', PUB.DtIni)
END
AND CASE PUB.DtFinal WHEN NULL
THEN
OP.DtInc <= Isnull('08/23/2013', OP.DtInc)
ELSE
PUB.DtFinal <= Isnull('08/23/2013', PUB.DtFinal)
END