我有2个SQL查询我试图使用linqer转换但没有结果。查询如下:
select distinct a.DOCID,
(select dcrea from mstdocs where DOCID = a.docid and vtype = 'table') DOC_DATE,
(select dcrea from mstdocs where DOCID= a.docid and vtype = 'read' and VTAID = '2') Read_DATE
from mstdocs a, mstdocstats b
where a.docid = b.docid
and a.vtaid = '2'
and a.vtype = 'read'
and DATEPART(mm,a.DCREA) = '06'
and DATEPART(yyyy,a.DCREA) = '2016'
and a.docid in
(
select distinct a.docid
from mstdocs a, mstdocstats b
where a.docid = b.docid
and a.vtype = 'table'
and DATEPART(mm,a.DCREA) = '06'
and DATEPART(yyyy,a.DCREA) = '2016'
)
select distinct a.docid
from mstdocs a, mstdocstats b
where a.docid = b.docid
and (select count(*) from mstdocs docs where docs.DOCID = a.docid and docs.vtaid = '2') = 1
我尝试将第一个查询分成两部分
var a =(来自mstdocstats中的b) 在a.docid上加入一个mstdocs等于b.docid 其中a.vtype.Equals(“表”) &安培;&安培; a.DCREA.Month =='06'&& a.DCREA.Year =='2016' 选择a.docid).Distinct()。ToList();
var b =(来自mstdocstats中的b
在a.docid上加入一个mstdocs等于b.docid
其中a.Contains(a.docid)
选择新{
docid = a.docid,
DOC_DATE =(来自mstdocs中的mstdoc,其中a.docid == mstdoc.docid&& mstdoc.vtype ==“table”选择
mstdoc.DCREA),
Read_DATE =(来自mstdocs中的mstdoc,其中a.docid == mstdoc.docid&& mstdoc.vtype ==“read”&&
mstdoc.vtaid ==“2”选择mstdoc.DCREA)})。ToList();
但是变成了错误,任何人都可以告诉我哪里出错了?
感谢您的回答...