date_from :datetime
date_to :datetime
cust: text (label:Yes , Value :Y & Label :No , value:N)
查询:
SELECT dbo.incident.incident_ref,Customer.cust_n,incident.date_logged
FROM incident
INNER JOIN Customer ON incident.incident_id = Customer.cust_id
WHERE incident.date_logged BETWEEN @date_from AND DATEADD(day, 1, @date_to)
我会根据dropdownlist
中的选择(包括ABC)在此处使用条件来显示客户
答案 0 :(得分:0)
您可以尝试将查询更改为:
SELECT dbo.incident.incident_ref,Customer.cust_n,incident.date_logged
FROM incident
INNER JOIN Customer ON incident.incident_id = Customer.cust_id
WHERE
incident.date_logged BETWEEN @date_from AND DATEADD(day, 1, @date_to) and
customer.cust_n = (case when @cust = 'N' and customer.cust_n = 'ABC' then NULL else customer.cust_n end)