获取Count以获得以下查询的答案

时间:2014-11-02 19:38:56

标签: mysql sql count

有人可以指导我如何计算此查询的答案吗?

SELECT      wo.Client_id
FROM        wish_order wo, 
            wish_order_fruit wof
WHERE       wo.wish_order_id = wof.wish_order_id 
GROUP BY    wof.wish_order_id 
HAVING      Count(wo.Client_id) > 1;

1 个答案:

答案 0 :(得分:0)

使用派生表获取该组按查询返回的行数

select count(*) from (
    select wo.Client_id
    from wish_order wo, wish_order_fruit wof
    where wo.wish_order_id = wof.wish_order_id 
    Group by wof.wish_order_id 
    having Count(wo.Client_id) >1
) t1