github.com/apache/beam/sdks/v2@v2.48.2/java/testing/tpcds/src/main/resources/queries/query65.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  	s_store_name,
    19  	i_item_desc,
    20  	sc.revenue,
    21  	i_current_price,
    22  	i_wholesale_cost,
    23  	i_brand
    24   from store, item,
    25       (select ss_store_sk, avg(revenue) as ave
    26   	from
    27   	    (select  ss_store_sk, ss_item_sk, 
    28   		     sum(ss_sales_price) as revenue
    29   		from store_sales, date_dim
    30   		where ss_sold_date_sk = d_date_sk and d_month_seq between 1212 and 1212+11
    31   		group by ss_store_sk, ss_item_sk) sa
    32   	group by ss_store_sk) sb,
    33       (select  ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue
    34   	from store_sales, date_dim
    35   	where ss_sold_date_sk = d_date_sk and d_month_seq between 1212 and 1212+11
    36   	group by ss_store_sk, ss_item_sk) sc
    37   where sb.ss_store_sk = sc.ss_store_sk and 
    38         sc.revenue <= 0.1 * sb.ave and
    39         s_store_sk = sc.ss_store_sk and
    40         i_item_sk = sc.ss_item_sk
    41   order by s_store_name, i_item_desc
    42  limit 100