github.com/apache/beam/sdks/v2@v2.48.2/java/testing/tpcds/src/main/resources/queries/query16.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 count(distinct cs_order_number) as `order count` 19 ,sum(cs_ext_ship_cost) as `total shipping cost` 20 ,sum(cs_net_profit) as `total net profit` 21 from 22 catalog_sales cs1 23 ,date_dim 24 ,customer_address 25 ,call_center 26 where 27 d_date between '2001-4-01' and 28 (cast('2001-4-01' as date) + interval '60' day) 29 and cs1.cs_ship_date_sk = d_date_sk 30 and cs1.cs_ship_addr_sk = ca_address_sk 31 and ca_state = 'NY' 32 and cs1.cs_call_center_sk = cc_call_center_sk 33 and cc_county in ('Ziebach County','Levy County','Huron County','Franklin Parish', 34 'Daviess County' 35 ) 36 and exists (select * 37 from catalog_sales cs2 38 where cs1.cs_order_number = cs2.cs_order_number 39 and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk) 40 and not exists(select * 41 from catalog_returns cr1 42 where cs1.cs_order_number = cr1.cr_order_number) 43 order by count(distinct cs_order_number) 44 limit 100