未知列 '2' “有序条款”

发布于 2024-10-11 10:29:15 字数 279 浏览 1 评论 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 

我不断收到此错误

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 

I am keep getting this error

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

唐婉 2024-10-18 10:29:15

你的语法在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'

your syntax is incorrect on the distinct... By using the (parens), it is thinking Distinct is a function and expecting the inner value as a parameter to pass and get a value back... what you want is... Additionally, since you have no other columns you are returning, you don't need a limit one... COUNT(*) or COUNT(DISTINCT SomeColumn) will ALWAYS return a single row all by itself... no group by needed.

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'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文