我想根據條件編寫一個複雜的SQL查詢。如果條件滿足,它應該用一個條件運行查詢,如果不是則另一個條件。這在SQL中如何實現?基於高級SQL條件的查詢構建
SELECT distinct support_id AS object_id, 2 as app_context_id,
0 as domain_cdc_id, 'S' as object_type,
'NEW' as domain_cdc_status, 1 as attribute_group_num,s
sysdate as created_on
FROM fdrdbo.v_facility_support
WHERE support_version_valid_from_dt = to_date('${passedInVar}', 'yyyy/mm/dd')
IF ${passedInVar}
爲空的話,我想用下面的WHERE條件,而不是:
WHERE SYSDATE BETWEEN support_version_valid_from_dt AND support_version_valid_to_dt
預先感謝您。
不能。這些數據來自業務數據源,並且在應用程序中修改查詢 – user836087
您使用的是什麼SQL引擎? MySQL,SQL Server,Oracle和Postgres都是不同的方言。 –