简体   繁体   中英

Unknown column '2' in 'order clause'

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

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'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM