Skip to content

Instantly share code, notes, and snippets.

@mportocarrero
mportocarrero / Successful women
Last active August 29, 2015 13:56
SUCCESSFUL WOMEN PROJECT - DRMII
TOP 100 SUCCESSFUL WOMEN IN THE WORLD (FORBES MAGAZINE)
How many women come from which country?
mysql> select country, count(*) from 100women group by country;
+----------------------+----------+
| country | count(*) |
+----------------------+----------+
| Argentina | 1 |
| Australia | 3 |
@mportocarrero
mportocarrero / Query ? - What was the evolution of people working and cycling everyday to work between 2001 and 2011 in Lewisham?
Created January 12, 2014 15:14
Query ? - What was the evolution of people working and cycling everyday to work between 2001 and 2011 in Lewisham?
Query in MySql:
mysql> select work_2001, bike_2001, work_2011, bike_2011 from cycling where borough = 'Lewisham';
+-----------+-----------+-----------+-----------+
| work_2001 | bike_2001 | work_2011 | bike_2011 |
+-----------+-----------+-----------+-----------+
| 114592 | 2112 | 136057 | 5375 |
+-----------+-----------+-----------+-----------+
1 row in set (0.00 sec)
@mportocarrero
mportocarrero / Query 22 - What was the evolution of people working and cycling everyday to work between 2001 and 2011 in Tower Hamlets?
Created January 12, 2014 15:12
Query 22 - What was the evolution of people working and cycling everyday to work between 2001 and 2011 in Tower Hamlets?
Query in MySql:
mysql> select work_2001, bike_2001, work_2011, bike_2011 from cycling where borough = 'Tower Hamlets';
+-----------+-----------+-----------+-----------+
| work_2001 | bike_2001 | work_2011 | bike_2011 |
+-----------+-----------+-----------+-----------+
| 73918 | 2214 | 120873 | 8112 |
+-----------+-----------+-----------+-----------+
1 row in set (0.00 sec)
@mportocarrero
mportocarrero / Query 21 - What is evolution of the percentage of people cycling everyday to work between 2001 and 2011 in Tower Hamlets?
Created January 12, 2014 15:03
Query 21 - What is evolution of the percentage of people cycling everyday to work between 2001 and 2011 in Tower Hamlets? This query shows if the percentage of people cycling everyday to work (from the people that work) increased or decreased between 2001 and 2011. It can be complemented with the difference between the two values.
Query in MySql:
mysql> SELECT percentage_2001, percentage_2011 from cycling where borough = 'Tower Hamlets' group by borough;
+-----------------+-----------------+
| percentage_2001 | percentage_2011 |
+-----------------+-----------------+
| 3.0 | 6.7 |
+-----------------+-----------------+
1 row in set (0.01 sec)
@mportocarrero
mportocarrero / Query 20 - In which areas of Tower Hamlets were the bikes stolen?
Created January 12, 2014 14:57
Query 20 - In which areas of Tower Hamlets were the bikes stolen? This query shows in which areas of Tower Hamlets the bikes were stolen and how many per area.
Query in MySql:
mysql> SELECT area, count(*) as count from bike where borough = 'Tower Hamlets' group by area;
+------------------------------------------------+-------+
| area | count |
+------------------------------------------------+-------+
| On or near Acton Mews | 2 |
| On or near Audrey Street | 1 |
| On or near Austin Street | 2 |
| On or near Bethnal Green Road | 1 |
@mportocarrero
mportocarrero / Query 19 - How is the police acting concerning to the bike theft cases in Tower Hamlets?
Created January 12, 2014 14:54
Query 19 - How is the police acting concerning to the bike theft cases in Tower Hamlets? This query shows what was the police resolution for the bike theft cases reported in Tower Hamlets.
Query in MySql:
mysql> SELECT borough, investigation, count(*) from bike where borough = 'Tower Hamlets' group by investigation;
+---------------+--------------------------------+----------+
| borough | investigation | count(*) |
+---------------+--------------------------------+----------+
| Tower Hamlets | No further action at this time | 41 |
| Tower Hamlets | Offender sent to prison | 1 |
| Tower Hamlets | Suspect charged | 3 |
| Tower Hamlets | Under investigation | 113 |
@mportocarrero
mportocarrero / Query 18 - How many bikes were stolen in average per month in Tower Hamlets from May to October 2013?
Created January 12, 2014 14:51
Query 18 - How many bikes were stolen in average per month in Tower Hamlets from May to October 2013? This query shows the average of bikes stolen per month in Tower Hamlets.
Query in MySql:
mysql> select borough, date, count(*) as count from bike where borough = 'Tower Hamlets' group by date;
+---------------+------------+-------+
| borough | date | count |
+---------------+------------+-------+
| Tower Hamlets | 2013-05-01 | 17 |
| Tower Hamlets | 2013-06-01 | 33 |
| Tower Hamlets | 2013-07-01 | 24 |
| Tower Hamlets | 2013-08-01 | 23 |
@mportocarrero
mportocarrero / Query 17 - How many bikes were stolen per month in Tower Hamlets from May to October 2013?
Created January 12, 2014 14:47
Query 17 - How many bikes were stolen per month in Tower Hamlets from May to October 2013? This query shows us the evolution of bike theft in Tower Hamlets in this period.
Query in MySql:
mysql> select borough, date, count(*) from bike where borough = 'Tower Hamlets' group by date;
+---------------+------------+----------+
| borough | date | count(*) |
+---------------+------------+----------+
| Tower Hamlets | 2013-05-01 | 17 |
| Tower Hamlets | 2013-06-01 | 33 |
| Tower Hamlets | 2013-07-01 | 24 |
| Tower Hamlets | 2013-08-01 | 23 |
@mportocarrero
mportocarrero / Query 16 - What is evolution of the percentage of people cycling everyday to work between 2001 and 2011 in Lewisham?
Last active January 3, 2016 00:49
Query 16 - What is evolution of the percentage of people cycling everyday to work between 2001 and 2011 in Lewisham? This query shows if the percentage of people cycling everyday to work (from the people that work) increased or decreased between 2001 and 2011. It can be complemented with the difference between the two values.
Query in MySql:
mysql> select percentage_2001, percentage_2011 from cycling where borough = 'Lewisham' group by borough;
+-----------------+-----------------+
| percentage_2001 | percentage_2011 |
+-----------------+-----------------+
| 1.8 | 4.0 |
+-----------------+-----------------+
1 row in set (0.01 sec)
@mportocarrero
mportocarrero / Query 15 - Where did people that cycled everyday to work in 2001 and 2011 live?
Created January 12, 2014 13:45
Query 15 - Where did people that cycled everyday to work in 2001 and 2011 live? This query allows the reader to understand which are the boroughs that were cycling the most and the least in 2001 and 2011.
Query in MySql:
2001:
mysql> select borough, bike_2001 from cycling group by borough;
+---------------+-----------+
| borough | bike_2001 |
+---------------+-----------+
| Croydon | 1636 |
| Greenwich | 1351 |