github.com/apache/beam/sdks/v2@v2.48.2/java/testing/tpcds/src/main/resources/queries/query13.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 avg(ss_quantity)
    18         ,avg(ss_ext_sales_price)
    19         ,avg(ss_ext_wholesale_cost)
    20         ,sum(ss_ext_wholesale_cost)
    21   from store_sales
    22       ,store
    23       ,customer_demographics
    24       ,household_demographics
    25       ,customer_address
    26       ,date_dim
    27   where s_store_sk = ss_store_sk
    28   and  ss_sold_date_sk = d_date_sk and d_year = 2001
    29   and((ss_hdemo_sk=hd_demo_sk
    30    and cd_demo_sk = ss_cdemo_sk
    31    and cd_marital_status = 'D'
    32    and cd_education_status = '2 yr Degree'
    33    and ss_sales_price between 100.00 and 150.00
    34    and hd_dep_count = 3   
    35       )or
    36       (ss_hdemo_sk=hd_demo_sk
    37    and cd_demo_sk = ss_cdemo_sk
    38    and cd_marital_status = 'S'
    39    and cd_education_status = 'Secondary'
    40    and ss_sales_price between 50.00 and 100.00   
    41    and hd_dep_count = 1
    42       ) or 
    43       (ss_hdemo_sk=hd_demo_sk
    44    and cd_demo_sk = ss_cdemo_sk
    45    and cd_marital_status = 'W'
    46    and cd_education_status = 'Advanced Degree'
    47    and ss_sales_price between 150.00 and 200.00 
    48    and hd_dep_count = 1  
    49       ))
    50   and((ss_addr_sk = ca_address_sk
    51    and ca_country = 'United States'
    52    and ca_state in ('CO', 'IL', 'MN')
    53    and ss_net_profit between 100 and 200  
    54       ) or
    55       (ss_addr_sk = ca_address_sk
    56    and ca_country = 'United States'
    57    and ca_state in ('OH', 'MT', 'NM')
    58    and ss_net_profit between 150 and 300  
    59       ) or
    60       (ss_addr_sk = ca_address_sk
    61    and ca_country = 'United States'
    62    and ca_state in ('TX', 'MO', 'MI')
    63    and ss_net_profit between 50 and 250  
    64       ))