[r13]: trunk / bibm / tpch / sparqlbi / query18.txt Maximize Restore History

Download this file

query18.txt    33 lines (31 with data), 936 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
define sql:signal-void-variables 1
prefix tpcd: <http://www.openlinksw.com/schemas/tpcd#>
prefix oplsioc: <http://www.openlinksw.com/schemas/oplsioc#>
prefix sioc: <http://rdfs.org/sioc/ns#>
prefix foaf: <http://xmlns.com/foaf/0.1/>
select
?cust+>foaf:c_name
?cust+>tpcd:c_custkey
?ord+>tpcd:o_orderkey
?ord+>tpcd:o_orderdate
?ord+>tpcd:o_ordertotalprice
sum(?li+>tpcd:l_linequantity)
from <http://example.com/tpcd>
where
{
?cust a tpcd:customer ;
foaf:c_name ?c_name .
?ord a tpcd:o_order ;
tpcd:o_has_customer ?cust .
?li a tpcd:lineitem ;
tpcd:l_has_order ?ord .
{
select ?sum_order sum (?li2+>tpcd:l_linequantity) as ?sum_q
where
{
?li2 a tpcd:lineitem ; tpcd:l_has_order ?sum_order .
}
} .
filter (?sum_order = ?ord and ?sum_q > %QUANTITY%)
}
order by desc (?ord+>tpcd:o_ordertotalprice) ?ord+>tpcd:o_orderdate