/* 1 Selection 1.1 Without Index */ select count(*) from Roads where Name starts "Univers" select * from Buildings where GeoData intersects eichlinghofen /* 1.2 Creating a Standard Index */ create index on Roads columns Name /* 1.3 Using a Standard Index */ select count(*) from Roads where Name starts "Univers" /* 1.4 Creating a Spatial Index */ create index on Buildings columns GeoData /* 1.5 Using a Spatial Index */ select * from Buildings where GeoData intersects eichlinghofen /* 2 Join 2.1 Equijoin */ select * from [Natural as n1, Natural as n2] where [n1:Name = n2:Name, n1:Osm_id < n2:Osm_id] /* 2.2 Spatial Join */ select count(*) from [Roads as r, Waterways as w] where r:GeoData intersects w:GeoData /* Expressions in the Select Clause */ select [r:Osm_id, r:Name, w:Osm_id, w:Name, intersection(r:GeoData, w:GeoData) as BridgePosition] from [Roads as r, Waterways as w] where r:GeoData intersects w:GeoData /* 2.3 General Join */ select * from [Roads as r, Waterways as w] where [r:Name contains w:Name, r:Type contains "pedestrian", w:Type contains "river"] /* 2.4 Index-Based Equijoin */ select * from [Roads as r1, Roads] where [r1:Name = Name, r1:Osm_id < Osm_id, r1:Type contains "raceway"] /* 2.5 Index-Based Spatial Join */ // select count(*) from [Roads as r, Buildings as b] // where [distance(gk(r:GeoData), gk(b:GeoData)) < 500, // r:Type contains "raceway"] /* 3 Aggregation 3.1 Counting */ select [Type, count(*) as Cnt] from Roads groupby Type /* 3.2 Sum, Average */ select [Type, avg(Width) as AWidth] from Waterways where between(Width, 0, 10000) groupby[Type]