[英]How can I avoid zero values in an aggregate?
我有一個查詢正確地拉回數據,但大約四分之一的數據行是不必要的,因為它們在主數據字段中有 0。 這是我編寫的用於創建該主要數據字段的行。 如何排除 amort_FY2020 的輸出值為 0 的任何情況?
sum(case when f.sales_revenue_period_calendar_sid in ('20200101',
'20200201',
'20200301',
'20200401',
'20200501',
'20200601',
'20200701',
'20200801',
'20200901',
'20201001',
'20201101',
'20201201')
then f.sales_revenue_before_tax_usd_amount
else 0 end) as amort_FY2020
根據您的數據庫,您可以使用:
having amort_FY2020 <> 0
或者可能需要重復表達式:
sum(case when f.sales_revenue_period_calendar_sid in ('20200101','20200201','20200301','20200401','20200501','20200601','20200701','20200801','20200901','20201001','20201101','20201201')
then f.sales_revenue_before_tax_usd_amount else 0
end) <> 0
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.