SELECT
*
FROM
dbo.TABLE
LEFT JOIN
table_insp insp ON TABLE.FORM_NO = insp.FORM_no
WHERE
(O_NMBR IS NOT NULL)
OR (O_DRCTN IS NOT NULL)
OR (O_INCHES IS NOT NULL)
OR (o_comments IS NOT NULL)
AND insp.COMPLETED_DATE >= '10-01-2018'
日期过滤不起作用。如果我取出所有IS NOT NULL,它工作正常。我如何让IS NOT NULL和日期过滤一起工作,为什么会这样呢?
答案 0 :(得分:1)
在()
中添加OR
SELECT * from dbo.TABLE
left join table_insp insp on TABLE.FORM_NO = insp.FORM_no
where (
(O_NMBR is not null)
OR (O_DRCTN is not null)
or (O_INCHES is not null)
or (o_comments is not null)
)
and insp.COMPLETED_DATE >= '10-01-2018'
答案 1 :(得分:0)
您需要用括号将<!DOCTYPE html>
<html>
<head>
<style>
</style>
</head>
<body>
<h2>Colored Table Header</h2>
<table>
<tbody>
<tr>
<td >ID</td>
<td>Name</td>
<td>Description</td>
<td>Value</td>
<td>Units</td>
<td>Directions</td>
</tr>
</tbody>
<tbody>
<tr>
<td >1</td>
<td>name1</td>
<td>Description1</td>
<td>Value1</td>
<td>Unit1</td>
<td>Direction1</td>
</tr>
</tbody>
<tbody>
<tr>
<td >2</td>
<td>name2</td>
<td>Description2</td>
<td>Value2</td>
<td>Unit2</td>
<td>Direction1</td>
</tr>
</tbody>
<tbody>
<tr>
<td >3</td>
<td>name3</td>
<td>Description3</td>
<td>Value3</td>
<td>Unit3</td>
<td>Direction3</td>
</tr>
</tbody>
<tbody>
<tr>
<td >4</td>
<td>name4</td>
<td>Description4</td>
<td>Value4</td>
<td>Unit4</td>
<td>Direction4</td>
</tr>
</tbody><tbody>
<tr>
<td >1</td>
<td>name1</td>
<td>Description1</td>
<td>Value1</td>
<td>Unit1</td>
<td>Direction1</td>
</tr>
</tbody>
<tbody>
<tr>
<td >2</td>
<td>name2</td>
<td>Description2</td>
<td>Value2</td>
<td>Unit2</td>
<td>Direction1</td>
</tr>
</tbody>
<tbody>
<tr>
<td >3</td>
<td>name3</td>
<td>Description3</td>
<td>Value3</td>
<td>Unit3</td>
<td>Direction3</td>
</tr>
</tbody>
<tbody>
<tr>
<td >4</td>
<td>name4</td>
<td>Description4</td>
<td>Value4</td>
<td>Unit4</td>
<td>Direction4</td>
</tr>
</tbody><tbody>
<tr>
<td >1</td>
<td>name1</td>
<td>Description1</td>
<td>Value1</td>
<td>Unit1</td>
<td>Direction1</td>
</tr>
</tbody>
<tbody>
<tr>
<td >2</td>
<td>name2</td>
<td>Description2</td>
<td>Value2</td>
<td>Unit2</td>
<td>Direction1</td>
</tr>
</tbody>
<tbody>
<tr>
<td >3</td>
<td>name3</td>
<td>Description3</td>
<td>Value3</td>
<td>Unit3</td>
<td>Direction3</td>
</tr>
</tbody>
<tbody>
<tr>
<td >4</td>
<td>name4</td>
<td>Description4</td>
<td>Value4</td>
<td>Unit4</td>
<td>Direction4</td>
</tr>
</tbody>
<tbody>
<tr>
<td >1</td>
<td>name1</td>
<td>Description1</td>
<td>Value1</td>
<td>Unit1</td>
<td>Direction1</td>
</tr>
</tbody>
<tbody>
<tr>
<td >2</td>
<td>name2</td>
<td>Description2</td>
<td>Value2</td>
<td>Unit2</td>
<td>Direction1</td>
</tr>
</tbody>
<tbody>
<tr>
<td >3</td>
<td>name3</td>
<td>Description3</td>
<td>Value3</td>
<td>Unit3</td>
<td>Direction3</td>
</tr>
</tbody>
<tbody>
<tr>
<td >4</td>
<td>name4</td>
<td>Description4</td>
<td>Value4</td>
<td>Unit4</td>
<td>Direction4</td>
</tr>
</tbody>
<tbody>
<tr>
<td >1</td>
<td>name1</td>
<td>Description1</td>
<td>Value1</td>
<td>Unit1</td>
<td>Direction1</td>
</tr>
</tbody>
<tbody>
<tr>
<td >2</td>
<td>name2</td>
<td>Description2</td>
<td>Value2</td>
<td>Unit2</td>
<td>Direction1</td>
</tr>
</tbody>
<tbody>
<tr>
<td >3</td>
<td>name3</td>
<td>Description3</td>
<td>Value3</td>
<td>Unit3</td>
<td>Direction3</td>
</tr>
</tbody>
<tbody>
<tr>
<td >4</td>
<td>name4</td>
<td>Description4</td>
<td>Value4</td>
<td>Unit4</td>
<td>Direction4</td>
</tr>
</tbody>
</table>
</body>
</html>
条件包装起来:
Formatter.format
答案 2 :(得分:0)
我认为您需要做的就是添加括号,例如:
new java.util.Formatter().format("n=%s, p=%s","name", "pass").toString()
答案 3 :(得分:0)
您需要在OR
条件周围加上括号。我还建议您使用标准日期格式:
where (O_NMBR is not null or O_DRCTN is not null or O_INCHES is not null or o_comments is not null
) and
insp.COMPLETED_DATE >= '2018-10-01'