github.com/apache/beam/sdks/v2@v2.48.2/java/testing/tpcds/src/main/resources/queries/query97.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  with ssci as (
    18  select ss_customer_sk customer_sk
    19        ,ss_item_sk item_sk
    20  from store_sales,date_dim
    21  where ss_sold_date_sk = d_date_sk
    22    and d_month_seq between 1212 and 1212 + 11
    23  group by ss_customer_sk
    24          ,ss_item_sk),
    25  csci as(
    26   select cs_bill_customer_sk customer_sk
    27        ,cs_item_sk item_sk
    28  from catalog_sales,date_dim
    29  where cs_sold_date_sk = d_date_sk
    30    and d_month_seq between 1212 and 1212 + 11
    31  group by cs_bill_customer_sk
    32          ,cs_item_sk)
    33   select  sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only
    34        ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only
    35        ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog
    36  from ssci full outer join csci on (ssci.customer_sk=csci.customer_sk
    37                                 and ssci.item_sk = csci.item_sk)
    38  limit 100