github.com/apache/beam/sdks/v2@v2.48.2/java/testing/tpcds/src/main/resources/queries/query18.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 ca_country, 19 ca_state, 20 ca_county, 21 avg( cast(cs_quantity as decimal(12,2))) agg1, 22 avg( cast(cs_list_price as decimal(12,2))) agg2, 23 avg( cast(cs_coupon_amt as decimal(12,2))) agg3, 24 avg( cast(cs_sales_price as decimal(12,2))) agg4, 25 avg( cast(cs_net_profit as decimal(12,2))) agg5, 26 avg( cast(c_birth_year as decimal(12,2))) agg6, 27 avg( cast(cd1.cd_dep_count as decimal(12,2))) agg7 28 from catalog_sales, customer_demographics cd1, 29 customer_demographics cd2, customer, customer_address, date_dim, item 30 where cs_sold_date_sk = d_date_sk and 31 cs_item_sk = i_item_sk and 32 cs_bill_cdemo_sk = cd1.cd_demo_sk and 33 cs_bill_customer_sk = c_customer_sk and 34 cd1.cd_gender = 'M' and 35 cd1.cd_education_status = 'College' and 36 c_current_cdemo_sk = cd2.cd_demo_sk and 37 c_current_addr_sk = ca_address_sk and 38 c_birth_month in (9,5,12,4,1,10) and 39 d_year = 2001 and 40 ca_state in ('ND','WI','AL' 41 ,'NC','OK','MS','TN') 42 group by rollup (i_item_id, ca_country, ca_state, ca_county) 43 order by ca_country, 44 ca_state, 45 ca_county, 46 i_item_id 47 limit 100