select
product_name,
convert(sum((succ_fail) * price), signed) as total
from
(
select
ucl.product_id,
(
case
when step="select" then 1
else 0
end
) as succ_fail,
price,
product_name
from
user_client_log as ucl
inner join product_info as pi on ucl.product_id=pi.product_id
) as tmp
group by product_id
order by total desc
limit 2
注意
case when step="select" then 1 else 0 end
神人题目说的不清不楚.....


京公网安备 11010502036488号