如何在percona中使用group by for one field

时间:2016-11-19 10:58:05

标签: sql percona

select SQL_CALC_FOUND_ROWS lead_fields.firstname AS `First Name`,TRIM(CONCAT(lead_fields.firstname,'
 ',lead_fields.lastname)) AS `Name`,lead_fields.organization AS `Organization Name`,lead_fields.email
 AS `Email`,lead_fields.main_phone AS `Main Phone`,lead_fields.lead_status AS `Lead status`,TRIM(CONCAT
(owner_id_1.firstname,' ',owner_id_1.lastname)) AS `Owner ID`,lead_fields.created_by_date_time AS `Created
 by date/time`,lead_fields.master_record_id as `Master Record ID`, IFNULL(image,'') `Image`, ifnull(owner_id_1
.pic_url,'') as `Owner Logo`,CASE WHEN (module_selector = 1 AND module_selector_details = 0 AND lead_fields
.owner_id ='U_550ce85b-8482-11e6-abba-b0aa7796770a') THEN 1  WHEN (module_selector = 0 AND module_selector_details
 = 0 ) THEN 1 WHEN (module_selector = 1 AND module_selector_details = 1 ) THEN 1 ELSE 0 END AS edit_delete_data
  from lead_fields LEFT OUTER JOIN  ( SELECT * FROM lookup_users WHERE app_id =  '205' ) owner_id_1 on
 lead_fields.app_id=owner_id_1.app_id and lead_fields.owner_id=owner_id_1.master_record_id LEFT JOIN
 lead_extra_fields_value on lead_fields.app_id=lead_extra_fields_value.app_id AND lead_fields.master_record_id
=lead_extra_fields_value.master_record_id LEFT JOIN user_module_data_sharing umds ON lead_fields.app_id
 = umds.app_id AND umds.module_id ='1'  where IFNULL(isdeleted_recycle_bin,0)= 0  and lead_fields.app_id
 = '205' AND  lead_fields.owner_id IN  ('U_550ce85b-8482-11e6-abba-b0aa7796770a' )   and ( 1=1  )   AND
 NOT EXISTS ( SELECT 1 FROM module_conversion_master mcm  WHERE mcm.source_object_id =  lead_fields.master_record_id
  ) and ( 1=1  and (lead_fields.owner_id IN ( 'U_550ce85b-8482-11e6-abba-b0aa7796770a')  or lead_fields
.owner_id IN ( 'U_ab8f7e49-94ed-11e6-b117-b0aa7796770a','U_4a9ff606-94ee-11e6-b117-b0aa7796770a') OR
 (lead_fields.owner_id IN ( 'U_550ce85b-8482-11e6-abba-b0aa7796770a' )  AND  1 = 1  )))  GROUP BY lead_fields
.master_record_id ORDER BY `First Name` asc limit 0 , 5;

此查询出错:

  

#1055 - 'crmdatabase.lead_fields.firstname'不在GROUP BY中

1 个答案:

答案 0 :(得分:0)

我认为在您的数据库中,lead_fields是一个视图,您必须检查此视图定义