github.com/apache/beam/sdks/v2@v2.48.2/java/testing/tpcds/src/main/resources/queries/query81.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 customer_total_return as 18 (select cr_returning_customer_sk as ctr_customer_sk 19 ,ca_state as ctr_state, 20 sum(cr_return_amt_inc_tax) as ctr_total_return 21 from catalog_returns 22 ,date_dim 23 ,customer_address 24 where cr_returned_date_sk = d_date_sk 25 and d_year =1998 26 and cr_returning_addr_sk = ca_address_sk 27 group by cr_returning_customer_sk 28 ,ca_state ) 29 select c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name 30 ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset 31 ,ca_location_type,ctr_total_return 32 from customer_total_return ctr1 33 ,customer_address 34 ,customer 35 where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 36 from customer_total_return ctr2 37 where ctr1.ctr_state = ctr2.ctr_state) 38 and ca_address_sk = c_current_addr_sk 39 and ca_state = 'IL' 40 and ctr1.ctr_customer_sk = c_customer_sk 41 order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name 42 ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset 43 ,ca_location_type,ctr_total_return 44 limit 100