and t.dcqcpjkd > round(AVG(WIDTHEXITCUSTOMER),1) 怎么让这个过滤条件不报错 想让这个字段大于平均数。 这样写行吗 我刚网上百度了下 加个子查询 t.dcqcpjkd > (select round(AVG(WIDTHEXITCUSTOMER),1) from l2l3pdo_data)想让每行中 zxkd 中最小的数据 大于htkd 这样写也不对吗 想实现zxkd小于htkd 不参与平均数的计算 SELECT t1.jcjhh, t1.gz, count( DISTINCT ( t1.zllh ) ) num_, DATE_FORMAT( min( t.ENDCOILING ), '%Y-%m-%d %H:%i:%s' ) kjsj, DATE_FORMAT( max( t.ENDCOILING ), '%Y-%m-%d %H:%i:%s' ) tjsj, round( AVG( WIDTHEXITCUSTOMER ), 1 ) htkd, round( AVG( dcqcpjkd ), 1 ) pjkd, round( max( dcqcpjkd ), 1 ) zdkd, round( min( dcqcpjkd ), 1 ) zxkd FROM l2l3pdo_data t, m_lcjh t1 WHERE t.AIMHEATID = t1.zllh AND t.SLABID BETWEEN '${bphmin}' AND '${bphmax}' GROUP BY t1.jcjhh, t1.gz HAVING zxkd > htkd ORDER BY t1.jcjhh, t1.gz, t1.zllh