Está en la página 1de 4

Mostrar los estudiantes que viven en el distrito 5 (San roque)

select ge, nombre, calle


from distritos a, estudiantes2019 b
where st_contains(the_geom, ge) =TRUE and a.id=5

Mostrar los distritos que estan alrededor del didtrito 5

select b.the_geom
from distritos a, distritos b
where st_touches(a.the_geom, b.the_geom) and a.id=5

mostrar las calles que que cruzan la av. Murillo


select b.geom, b.nombrec
from calles a, calles b
where st_crosses(a.geom, b.geom) and a.nombrec='Av. Pedro Domingo Murill

Mostrar los estudiantes que viven por lo menos a una distancia de


190 m a la calle Av. Arce

select b.ge,nombre
from calles a, estudiantes2019 b
where st_dwithin(a.geom, b.ge,190) and a.nombrec='Av. Arce'

Conjuncionar el distrito 5 y 9

select st_union(a.the_geom,b.the_geom)
from distritos a, distritos b
where a.id=5 and b.id=9

Mostrar los estudiantes que viven en el distrito 5 y 1

select ge,nombre
from estudiantes2019 a,
(select st_union(a.the_geom,b.the_geom) as gg
from distritos a, distritos b
where a.id=5 and b.id=1) as b
where st_within(ge,gg)

____________________________________
Potosi, 20 de mayo

Mostrar la calle mas larga del distrito 10 (Satelite)

select geom,nombrec, st_length(geom) as l


from
(select geom, nombrec
from distritos a, calles b
where st_within(geom, the_geom) and a.id=10) as t
order by l desc
limit 1

Mostrar la calle mas larga que cruza la Av. Murillo


select geom,nombrec, st_length(geom) as l
from
(select b.geom, b.nombrec
from calles a, calles b
where st_crosses(a.geom, b.geom) and a.nombrec='Av. Pedro Domingo
Murillo') as t
order by l desc
limit 1

Mostrar la provincia mas grande del Depto. de Potosi

select g, nom_prov, st_area(g) as a


from
(select nom_prov,st_union(the_geom) as g
from muni_poto_z19
group by nom_prov) as t
order by a desc
limit 1

Mostrar la provincias cuya superficie sea mayor a 8000 millones


de metros cuadrados

select g, nom_prov, st_area(g) as a


from
(select nom_prov,st_union(the_geom) as g
from muni_poto_z19
group by nom_prov) as t
where st_area(g)>8000000000

select nom_prov,st_union(the_geom) as g, st_area(st_union(the_geom))


from muni_poto_z19
group by nom_prov
having st_area(st_union(the_geom))>8000000000

En la poblacion de Puna se ha generado una epidemia por lo cual


el Ministerio de Salud a declarado cuarentena a las escuelas
que estan a una distancia de por lo menos 5000 m.

select a.geom,unidad_edu
from escuelas_potosi a,
(select geom, nombre, st_buffer(geom, 5000) as f
from centros_po20
where nombre='Puna') as b
where st_within(a.geom,f)

Mostrar al estudiante que vive mas cerca de la Universidad

select geom, nombre, st_distance(geom,u) as d


from estudiantes x,
(select st_intersection(a.geom, b.geom) as u
from callesp a, callesp b
where a.nombrec='Av. Civica' and b.nombrec='Serrudo') as y
order by d
limit 1

Mostrar al estudiante que vive mas cerca de la Iglesia Jerusalen

select b.geom, nombre, st_distance(a.geom,b.geom) as d


from iglesiasp a, estudiantes b
where a.nombrei='JERUSALEN'
order by d
limit 1

Mostrar el distrito que mas iglesias tiene

select a.geom,nombred, count(*) as c


from distritosp a, iglesiasp b
where st_within(b.geom,a.geom)
group by nombred,a.geom
order by c desc
limit 1

Mostrar los distritos que tienen mas de dos iglesia

select a.geom,nombred, count(*) as c


from distritosp a, iglesiasp b
where st_within(b.geom,a.geom)
group by nombred,a.geom
having count(*)>2

Mostrar el hospital mas cercano a la escuela 'Litoral'

select a.geom,nombrees, st_distance(a.geom,b.geom) as d


from establecimientosaludp a, escuelasp b
where b.nombree='LITORAL A,LITORAL C'
ORDER BY D
LIMIT 1

_______________________________
con la base de datos Potosi

Mostrar los municipios que estan alrededor del


municipio de Chaqui'

select a.geom,a.nombree
from municipios a, municipios b
where st_touches(a.geom,b.geom) and b.nombree='Chaqui'

Mostrar las centros poblados de la provincia mas grande

select geom,nombrecp
from centros_pobla a,
(select g, st_area(g) as a
from
(select distrito,st_union(geom) as g
from municipios
group by distrito) as t
order by a desc
limit 1) as b
where st_within(a.geom,g)

También podría gustarte