github.com/apache/beam/sdks/v2@v2.48.2/java/testing/tpcds/src/main/resources/queries/query29.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 18 i_item_id 19 ,i_item_desc 20 ,s_store_id 21 ,s_store_name 22 ,sum(ss_quantity) as store_sales_quantity 23 ,sum(sr_return_quantity) as store_returns_quantity 24 ,sum(cs_quantity) as catalog_sales_quantity 25 from 26 store_sales 27 ,store_returns 28 ,catalog_sales 29 ,date_dim d1 30 ,date_dim d2 31 ,date_dim d3 32 ,store 33 ,item 34 where 35 d1.d_moy = 4 36 and d1.d_year = 1999 37 and d1.d_date_sk = ss_sold_date_sk 38 and i_item_sk = ss_item_sk 39 and s_store_sk = ss_store_sk 40 and ss_customer_sk = sr_customer_sk 41 and ss_item_sk = sr_item_sk 42 and ss_ticket_number = sr_ticket_number 43 and sr_returned_date_sk = d2.d_date_sk 44 and d2.d_moy between 4 and 4 + 3 45 and d2.d_year = 1999 46 and sr_customer_sk = cs_bill_customer_sk 47 and sr_item_sk = cs_item_sk 48 and cs_sold_date_sk = d3.d_date_sk 49 and d3.d_year in (1999,1999+1,1999+2) 50 group by 51 i_item_id 52 ,i_item_desc 53 ,s_store_id 54 ,s_store_name 55 order by 56 i_item_id 57 ,i_item_desc 58 ,s_store_id 59 ,s_store_name 60 limit 100