Skip to content

Instantly share code, notes, and snippets.

@LoganWinston
LoganWinston / gist:2ba03c98ccedb272a391
Created February 4, 2015 20:17
GROUP BY e.g in SQL ... make sure to select all of the relevant columns in after the SELECT column
SELECT count(*), state
FROM compcorp
GROUP BY state
@LoganWinston
LoganWinston / gist:06e1c73e184462cc1173
Created January 29, 2015 20:43
Calculate Area in Square Feet using ST_Area - insert new column called area first
Update extracttokml_9_ set area =(ST_Area(the_geom_webmercator) * 10.7639)
@LoganWinston
LoganWinston / Intro_CartoDB.md
Last active August 29, 2015 14:11
Intro_CartoDB
@LoganWinston
LoganWinston / gist:c7c93549b02a51f3e76c
Created November 17, 2014 17:21
Select State from 50 States
SELECT ne_50m_admin_1_states.the_geom, ne_50m_admin_1_states.the_geom_webmercator, ne_50m_admin_1_states.cartodb_id FROM ne_50m_admin_1_states WHERE ne_50m_admin_1_states.name = 'Texas'
@LoganWinston
LoganWinston / gist:2086419854601869a1c5
Last active August 29, 2015 14:09
Table Join: Select Turbines from Polygons (from which you can perform a Chloropleth)
SELECT tl_2010_48_county10_dpsf.name10, usgs_windturbine_201307.the_geom, usgs_windturbine_201307.the_geom_webmercator, usgs_windturbine_201307.cartodb_id,
usgs_windturbine_201307.mw_turbine,
usgs_windturbine_201307.manufac,
usgs_windturbine_201307.on_year, usgs_windturbine_201307.blade_l, usgs_windturbine_201307.rotor_dia, usgs_windturbine_201307.model,
usgs_windturbine_201307.tower_h, usgs_windturbine_201307.total_ht
FROM usgs_windturbine_201307, tl_2010_48_county10_dpsf WHERE
ST_Intersects(usgs_windturbine_201307.the_geom, tl_2010_48_county10_dpsf.the_geom)
@LoganWinston
LoganWinston / gist:42a4e7b0da94fc65ffa7
Last active August 29, 2015 14:09
Andrew X. Hill's Fun Sql
--PART 2
-- a.
SELECT * FROM tornados
SELECT cartodb_id FROM tornados
-- b.
SELECT * FROM tornados LIMIT 1
SELECT * FROM tornados LIMIT 1 OFFSET 1
SELECT * FROM tornados ORDER BY damage DESC LIMIT 10
--PART 2
-- a.
SELECT * FROM tornados
SELECT cartodb_id FROM tornados
-- b.
SELECT * FROM tornados LIMIT 1
SELECT * FROM tornados LIMIT 1 OFFSET 1
SELECT * FROM tornados ORDER BY damage DESC LIMIT 10
-- c.
SELECT * FROM tornados WHERE cartodb_id < 30