-3

我需要将用户选择的日期(DocDate)添加到以下查询

SELECT  DocNum, CardCode, CardName FROM ORDR WHERE DOCENTRY NOT IN(

select DISTINCT(T0.DOCENTRY)
from ORDR T0 JOIN RDR1 T1 ON T0.DOCENTRY = T1.DOCENTRY
LEFT JOIN OITM T2 ON T1.ITEMCODE = T2.ITEMCODE
LEFT JOIN OITB T3 ON T2.ItmsGrpCod = T3.ItmsGrpCod
WHERE T3.ItmsGrpNam = 'Carriage Out'
AND T0.DocType = 'I'


)
AND DOCTYPE = 'I' 
4

2 回答 2

0

where YEAR(t0.DocDate) = YEAR(@date)您发送的输入在哪里@date,您可以检查特定日期、同年或同月。

于 2016-01-12T17:34:16.013 回答
0

改进的查询 - 虽然还没有答案。

SELECT DocNum, CardCode, CardName
FROM ORDR
WHERE DOCENTRY NOT IN
    (
    select T0.DOCENTRY
    from ORDR T0
    JOIN RDR1 T1 ON T0.DOCENTRY = T1.DOCENTRY
    LEFT JOIN OITM T2 ON T1.ITEMCODE = T2.ITEMCODE
    LEFT JOIN OITB T3 ON T2.ItmsGrpCod = T3.ItmsGrpCod
                      AND T3.ItmsGrpNam = 'Carriage Out'
    WHERE T0.DocType = 'I'
    )
  AND DOCTYPE = 'I' 
于 2015-11-26T14:12:50.517 回答