github.com/apache/beam/sdks/v2@v2.48.2/java/testing/tpcds/src/main/resources/queries/query72.sql (about) 1 -- Licensed to the Apache Software Foundation (ASF) under one 2 -- or more contributor license agreements. See the NOTICE file 3 -- distributed with this work for additional information 4 -- regarding copyright ownership. The ASF licenses this file 5 -- to you under the Apache License, Version 2.0 (the 6 -- "License"); you may not use this file except in compliance 7 -- with the License. You may obtain a copy of the License at 8 -- 9 -- http://www.apache.org/licenses/LICENSE-2.0 10 -- 11 -- Unless required by applicable law or agreed to in writing, software 12 -- distributed under the License is distributed on an "AS IS" BASIS, 13 -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 -- See the License for the specific language governing permissions and 15 -- limitations under the License. 16 17 select i_item_desc 18 ,w_warehouse_name 19 ,d1.d_week_seq 20 ,count(case when p_promo_sk is null then 1 else 0 end) no_promo 21 ,count(case when p_promo_sk is not null then 1 else 0 end) promo 22 ,count(*) total_cnt 23 from catalog_sales 24 join inventory on (cs_item_sk = inv_item_sk) 25 join warehouse on (w_warehouse_sk=inv_warehouse_sk) 26 join item on (i_item_sk = cs_item_sk) 27 join customer_demographics on (cs_bill_cdemo_sk = cd_demo_sk) 28 join household_demographics on (cs_bill_hdemo_sk = hd_demo_sk) 29 join date_dim d1 on (cs_sold_date_sk = d1.d_date_sk) 30 join date_dim d2 on (inv_date_sk = d2.d_date_sk) 31 join date_dim d3 on (cs_ship_date_sk = d3.d_date_sk) 32 left outer join promotion on (cs_promo_sk=p_promo_sk) 33 left outer join catalog_returns on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number) 34 where d1.d_week_seq = d2.d_week_seq 35 and inv_quantity_on_hand < cs_quantity 36 and d3.d_date > d1.d_date + interval '5' day 37 and hd_buy_potential = '1001-5000' 38 and d1.d_year = 2001 39 and hd_buy_potential = '1001-5000' 40 and cd_marital_status = 'M' 41 and d1.d_year = 2001 42 group by i_item_desc,w_warehouse_name,d1.d_week_seq 43 order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq 44 limit 100