CIDADAO

select count(*) from cidadao;

select count(nome) from cidadao where nome like '%HUGO%';

select count(nome) from cidadao where nome like '%HUGO' and codpostal like 'BRAGA%';

select * from cidadao where nome like '%HUGO%' and  (codpostal like '4700%' or codpostal like '4710%');

MCDONALDS

select nome, st_astext(the_geom) from mcdonald where nome ilike '%BRAGA%';

select * from spatial_ref_sys where srid = 4326;

select st_astext(st_transform(st_geometryfromtext('POINT(-8.402944 41.547763)',4326),3763));

select nome, st_distance(
	the_geom, 
	st_transform(st_geometryfromtext('POINT(-8.427784 41.549899)',4326),3763)
	) as distancia
	from mcdonald 
	--where nome ilike '%BRAGA%'
	order by distancia

PLANET OSM POINT

select *
from planet_osm_point
limit 10

-8.42777, 41.549911

1. SELECT count(amenity) FROM planet_osm_polygon/point WHERE amenity ILIKE 'hospital';

2. select st_astext(st_transform(st_geometryfromtext('POINT(-8.42777 41.549911)',4326),3763));

3. SELECT freguesia FROM caop.caop2012 WHERE st_contains(caop2012.wkb_geometry, ST_transform(st_geometryfromtext('POINT(-8.42777 41.549911)',4326),3763));

4. SELECT nome, st_distance(
	the_geom, 
	st_transform(st_geometryfromtext('POINT(-8.42777 41.549911)',4326),3763)) 
	AS distancia
	FROM p 
	ORDER BY distancia
	LIMIT 1

5. SELECT amenity,count(amenity) 
	FROM public.planet_osm_point,caop.distrito 
	WHERE distrito 
	ILIKE 'porto' 
	GROUP BY amenity;