簡體   English   中英

如何在 where 子句中包含 COUNT function?

[英]How to include COUNT function in where clause?

我有一個客戶記錄表。 我正在嘗試僅獲取自特定日期以來訪問過 10 次以上的客戶的數據。 這是我現在得到的代碼。 任何幫助故障排除將不勝感激!

    Select 
         customer_id,
         order_id,
         order_date
    from Table1
    where order_date > '2020-02-01'
    group by customer_id
    having count(customer_id)>=10

您不應在 select 中混合分組列和“普通”列

select *
from table1
where customer_id in
(
    Select customer_id
    from Table1
    where order_date > '2020-02-01'
    group by customer_id
    having count(*) >= 10
)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM