例を確認しようとしています。日付がnullの場合は、別のフィールドから日付を選択してください。クエリの下:
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