github.com/apache/beam/sdks/v2@v2.48.2/java/testing/tpcds/src/main/resources/queries/query1.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 sr_customer_sk as ctr_customer_sk 19 ,sr_store_sk as ctr_store_sk 20 ,sum(sr_fee) as ctr_total_return 21 from store_returns 22 ,date_dim 23 where sr_returned_date_sk = d_date_sk 24 and d_year =2000 25 group by sr_customer_sk 26 ,sr_store_sk) 27 select c_customer_id 28 from customer_total_return ctr1 29 ,store 30 ,customer 31 where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2 32 from customer_total_return ctr2 33 where ctr1.ctr_store_sk = ctr2.ctr_store_sk) 34 and s_store_sk = ctr1.ctr_store_sk 35 and s_state = 'TN' 36 and ctr1.ctr_customer_sk = c_customer_sk 37 order by c_customer_id 38 limit 100