github.com/apache/beam/sdks/v2@v2.48.2/java/testing/tpcds/src/main/resources/queries/query17.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_id 18 ,i_item_desc 19 ,s_state 20 ,count(ss_quantity) as store_sales_quantitycount 21 ,avg(ss_quantity) as store_sales_quantityave 22 ,stddev_samp(ss_quantity) as store_sales_quantitystdev 23 ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov 24 ,count(sr_return_quantity) as store_returns_quantitycount 25 ,avg(sr_return_quantity) as store_returns_quantityave 26 ,stddev_samp(sr_return_quantity) as store_returns_quantitystdev 27 ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov 28 ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave 29 ,stddev_samp(cs_quantity) as catalog_sales_quantitystdev 30 ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov 31 from store_sales 32 ,store_returns 33 ,catalog_sales 34 ,date_dim d1 35 ,date_dim d2 36 ,date_dim d3 37 ,store 38 ,item 39 where d1.d_quarter_name = '1998Q1' 40 and d1.d_date_sk = ss_sold_date_sk 41 and i_item_sk = ss_item_sk 42 and s_store_sk = ss_store_sk 43 and ss_customer_sk = sr_customer_sk 44 and ss_item_sk = sr_item_sk 45 and ss_ticket_number = sr_ticket_number 46 and sr_returned_date_sk = d2.d_date_sk 47 and d2.d_quarter_name in ('1998Q1','1998Q2','1998Q3') 48 and sr_customer_sk = cs_bill_customer_sk 49 and sr_item_sk = cs_item_sk 50 and cs_sold_date_sk = d3.d_date_sk 51 and d3.d_quarter_name in ('1998Q1','1998Q2','1998Q3') 52 group by i_item_id 53 ,i_item_desc 54 ,s_state 55 order by i_item_id 56 ,i_item_desc 57 ,s_state 58 limit 100