【问题标题】:Get Count for the answer of the below query获取以下查询的答案的计数
【发布时间】:2014-11-02 19:38:56
【问题描述】:

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

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;

【问题讨论】:

  • 很难说你想做什么。您正在以一种难以理解的方式使用GROUP BY。你能澄清你的问题吗?
  • 这个查询的答案如下:
  • Client_Id ________ 6 7 2 我需要这个答案的计数。

标签: mysql sql count


【解决方案1】:

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

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

【讨论】:

  • @user3693592 这是派生表的名称
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-05
  • 2021-12-09
  • 1970-01-01
  • 1970-01-01
  • 2020-01-06
  • 1970-01-01
相关资源
最近更新 更多