select count(*) as n from tblcontact where email='' and officeid_fk in
--select count(*) as n from tblcontact where email='' and firstname='' and lastname='' and officeid_fk in
(
select officeid_pk from tbloffice where companyid_fk in
(
select companyid_fk from tblMCOCControl where contactnum>0 and ( RecordID_pk >= (SELECT max(RecordID_pk) AS RecordID_pk FROM tblMCOCControl WHERE contactnum>0 and RecordID_pk IN (SELECT TOP 1 RecordID_pk FROM tblMCOCControl where contactnum>0)) )AND (RecordID_pk <= (SELECT MAX(RecordID_pk) AS RecordID_pk FROM tblMCOCControl WHERE contactnum>0 and RecordID_pk IN (SELECT TOP 1000 RecordID_pk FROM tblMCOCControl where contactnum>0 ))))
)
本文通过一个复杂的SQL查询案例,展示了如何从一个大型的数据集中筛选特定条件的记录。该查询涉及多个表之间的连接操作、子查询以及聚合函数的使用等高级SQL特性。
3万+

被折叠的 条评论
为什么被折叠?



