我對 SQL 很陌生。我有這個表,如何撰寫代碼來過濾符合這些條件的行。按 item_revenue 列篩選的每個產品僅顯示至少有四個正數或四個負數的月份。所以結果應該只顯示二月的 product_A,一月和二月的 product_B。
要過濾的表
uj5u.com熱心網友回復:
試試這個:
select product_name, month
from mytable
group by product_name, month
having countif(item_revenue > 0) >= 4 OR countif(item_revenue < 0) >= 4
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/339064.html
標籤:sql 谷歌-bigquery
下一篇:從資料庫提交后,PHP保留下拉值
