github.com/apache/beam/sdks/v2@v2.48.2/java/testing/tpcds/src/main/resources/queries/query73.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 c_last_name 18 ,c_first_name 19 ,c_salutation 20 ,c_preferred_cust_flag 21 ,ss_ticket_number 22 ,cnt from 23 (select ss_ticket_number 24 ,ss_customer_sk 25 ,count(*) cnt 26 from store_sales,date_dim,store,household_demographics 27 where store_sales.ss_sold_date_sk = date_dim.d_date_sk 28 and store_sales.ss_store_sk = store.s_store_sk 29 and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk 30 and date_dim.d_dom between 1 and 2 31 and (household_demographics.hd_buy_potential = '>10000' or 32 household_demographics.hd_buy_potential = 'Unknown') 33 and household_demographics.hd_vehicle_count > 0 34 and case when household_demographics.hd_vehicle_count > 0 then 35 household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1 36 and date_dim.d_year in (1998,1998+1,1998+2) 37 and store.s_county in ('Williamson County','Williamson County','Williamson County','Williamson County') 38 group by ss_ticket_number,ss_customer_sk) dj,customer 39 where ss_customer_sk = c_customer_sk 40 and cnt between 1 and 5 41 order by cnt desc, c_last_name asc