Skip to content

Commit

Permalink
good
Browse files Browse the repository at this point in the history
Merge branch 'master' of https://github.com/merlintang/sgb
  • Loading branch information
Mingjie Tang committed Nov 13, 2015
2 parents 2d9faa7 + 268d263 commit 4455e1e
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,47 @@ http://www.postgresql.org/docs/9.2/static/install-procedure.html

## Sample Sql queries

```sql

//create table
CREATE TABLE tmp (
id integer,
col1 double,
col2 double
);

//insert data
insert into tmp values (1, 2.0,3.0)
insert into tmp values (2, 3.0,4.0)

//execute query
//SGB-All
select avg(col1) as centerx, avg(col2) as centery
min(col1) as p1x, min(col2) as p1y
max(col1) as p2x, max(col2) as p2y from tmp
group by col1, col2 distanceall within 2
on_overlap any
metric lone;

select avg(col1) as centerx, avg(col2) as centery
min(col1) as p1x, min(col2) as p1y
max(col1) as p2x, max(col2) as p2y from tmp
group by col1, col2 distanceall within 2
on_overlap eliminate
metric lone;

select avg(col1) as centerx, avg(col2) as centery
min(col1) as p1x, min(col2) as p1y
max(col1) as p2x, max(col2) as p2y from tmp
group by col1, col2 distanceall within 2
on_overlap new_group
metric lone;


//SGB-Any
select avg(col1) as centerx, avg(col2) as centery
min(col1) as p1x, min(col2) as p1y
max(col1) as p2x, max(col2) as p2y from table
group by col1, col2 distanceany within 2
metric lone;

0 comments on commit 4455e1e

Please sign in to comment.