尝试将选择添加到以下查询

时间:2015-11-26 13:31:33

标签: sql sapb1

我需要将用户选择的日期(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' 

2 个答案:

答案 0 :(得分: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' 

答案 1 :(得分:0)

public List<SoundFragment> GetFragment(String p) { List<SoundFragment> list1 = new List<SoundFragment>(); //make a list and store every string foreach(SoundFragment i in fragments) { if (i.Title.Contains(p)) { list1.Add(i); } } //return all the objects from the new list that stores all the string contained in the fragments list return list1; } 其中where YEAR(t0.DocDate) = YEAR(@date)是您发送的输入,您可以查看特定日期,同一年或同月。