github.com/apache/beam/sdks/v2@v2.48.2/java/testing/tpcds/src/main/resources/queries/query30.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 wr_returning_customer_sk as ctr_customer_sk 19 ,ca_state as ctr_state, 20 sum(wr_return_amt) as ctr_total_return 21 from web_returns 22 ,date_dim 23 ,customer_address 24 where wr_returned_date_sk = d_date_sk 25 and d_year =2002 26 and wr_returning_addr_sk = ca_address_sk 27 group by wr_returning_customer_sk 28 ,ca_state) 29 select c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag 30 ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address 31 ,c_last_review_date_sk,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,c_preferred_cust_flag 42 ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address 43 ,c_last_review_date_sk,ctr_total_return 44 limit 100