此查询有效
SELECT
branch
, total
, typeA/1.2 AS [A]
, typeB/1.2 AS [B]
, dates
, (typeA / 1.2 + typeB / 1.2) * 0.2 AS [V]
, (typeA / 1.2 + typeB / 1.2) * 0.2 + typeA / 1.2 + typeB / 1.2 - total AS [DIFF]
FROM
detail
WHERE
(branch = 'SW1'
AND method in ('Visa', 'Mcard') OR branch = 'SW1'
AND method = 'Coupon'
AND receipt = 'Y' OR branch = 'SW1'
AND method = 'Coupon'
AND qty <= 7)
AND dates Between '04/01/2015' And '04/30/2015'
ORDER BY
dates;
但我需要从表单中的控件获取分支数据,如
Select("branch = " + ComboBox1.Text).FirstOrDefault();
我在查询中有3个引用分支的条件。 如何删除对同一分支的多个引用,以便我可以在c#中使用表单控件。我有 尝试将分支转移到各种各样的职位之后 WHERE子句
答案 0 :(得分:0)
通过反复试验解决了问题。 从Where子句开始如下
WHERE dates Between '04/01/2015' And '04/30/2015'
AND (method in ('Visa','MCard')
OR method= 'Coupon'AND receipt='Y'
OR method='Coupon' AND qty<=5)
AND branch='SW1'