0
select count(distinct(vw_SIPMIP.product_id)) from vw_SIPMIP , sp_mip_rule  
where 
vw_SIPMIP.product_id not in (select a.product_id from vw_non_SIPMIP a) 
and sp_mip_rule.id = vw_SIPMIP.id 
and sp_mip_rule.createdby != '_IMPORT' limit 1 

我不断收到此错误

4

1 回答 1

1

您的语法在 distinct 上不正确...通过使用 (parens),它认为 Distinct 是一个函数并期望内部值作为参数传递并返回值...您想要的是...另外,由于您没有要返回的其他列,因此您不需要限制一... COUNT(*) 或 COUNT(DISTINCT SomeColumn) 将始终单独返回一行...不需要分组。

select count(distinct vw_SIPMIP.product_id) YourDistinctCount
   from vw_SIPMIP, 
        sp_mip_rule
   where  vw_SIPMIP.product_id not in (select a.product_id from vw_non_SIPMIP a)  
     and sp_mip_rule.id = vw_SIPMIP.id  
     and sp_mip_rule.createdby != '_IMPORT'
于 2011-01-10T23:51:31.493 回答