blob: 107bd4a5334757723d21af2ae3d378f5b12137ac [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
use dataverse tpch;
declare function revenue() {
for $l in dataset('LineItem')
where $l.l_shipdate >= '1996-01-01' and $l.l_shipdate < '1996-04-01'
group by $l_suppkey := $l.l_suppkey with $l
return {
"supplier_no": $l_suppkey,
"total_revenue": sum(for $i in $l return $i.l_extendedprice * (1 - $i.l_discount))
}
}
let $m := max(
for $r2 in revenue()
return $r2.total_revenue
)
for $s in dataset('Supplier')
for $r in revenue()
where $s.s_suppkey = $r.supplier_no and $r.total_revenue<$m+0.000000001 and $r.total_revenue>$m-0.000000001
return {
"s_suppkey": $s.s_suppkey,
"s_name": $s.s_name,
"s_address": $s.s_address,
"s_phone": $s.s_phone,
"total_revenue": $r.total_revenue
}