github.com/apache/beam/sdks/v2@v2.48.2/java/testing/tpcds/src/main/resources/queries/query95.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 ws_wh as
    18  (select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2
    19   from web_sales ws1,web_sales ws2
    20   where ws1.ws_order_number = ws2.ws_order_number
    21     and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk)
    22   select
    23     count(distinct ws_order_number) as `order count`
    24    ,sum(ws_ext_ship_cost) as `total shipping cost`
    25    ,sum(ws_net_profit) as `total net profit`
    26  from
    27     web_sales ws1
    28    ,date_dim
    29    ,customer_address
    30    ,web_site
    31  where
    32      d_date between '1999-5-01' and
    33             (cast('1999-5-01' as date) + interval '60' day)
    34  and ws1.ws_ship_date_sk = d_date_sk
    35  and ws1.ws_ship_addr_sk = ca_address_sk
    36  and ca_state = 'TX'
    37  and ws1.ws_web_site_sk = web_site_sk
    38  and web_company_name = 'pri'
    39  and ws1.ws_order_number in (select ws_order_number
    40                              from ws_wh)
    41  and ws1.ws_order_number in (select wr_order_number
    42                              from web_returns,ws_wh
    43                              where wr_order_number = ws_wh.ws_order_number)
    44  order by count(distinct ws_order_number)
    45  limit 100