github.com/apache/beam/sdks/v2@v2.48.2/java/testing/tpcds/src/main/resources/queries/query40.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     w_state
    19    ,i_item_id
    20    ,sum(case when (cast(d_date as date) < cast ('1998-04-08' as date))
    21   		then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before
    22    ,sum(case when (cast(d_date as date) >= cast ('1998-04-08' as date))
    23   		then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after
    24   from
    25     catalog_sales left outer join catalog_returns on
    26         (cs_order_number = cr_order_number
    27          and cs_item_sk = cr_item_sk)
    28    ,warehouse
    29    ,item
    30    ,date_dim
    31   where
    32       i_current_price between 0.99 and 1.49
    33   and i_item_sk          = cs_item_sk
    34   and cs_warehouse_sk    = w_warehouse_sk
    35   and cs_sold_date_sk    = d_date_sk
    36   and d_date between (cast ('1998-04-08' as date) - interval '30' day)
    37                  and (cast ('1998-04-08' as date) + interval '30' day)
    38   group by
    39      w_state,i_item_id
    40   order by w_state,i_item_id
    41  limit 100