Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # SELECT FROM LIMIT
- All of the information on the stations table.
- Max, min, and mean temp from the conditions table.
- id, start_station_id, and duration of five trips.
- SELECT * From stations;
- SELECT max_temperature_f, min_temperature_f, mean_temperature_f FROM conditions;
- SELECT id, start_station_id, duration FROM trips LIMIT 5;
- # WHERE
- Trips that started at the station with an id of 2.
- Stations that have a dock_count of 15.
- id, date, and precipitation for conditions with more than 1 inch of precipitation.
- SELECT * FROM trips WHERE start_station_id = 2;
- SELECT * FROM stations WHERE dock_count = 15;
- SELECT id, date, precipitation_inches FROM conditions WHERE precipitation_inches > 1;
- # max/min/count/average
- Duration of the longest trip.
- Duration of the shortest trip.
- Average dock_count at a station.
- Highest dock_count at a station.
- Count of days with no rain.
- Name/dock_count of the station with the most docks.
- Id, start station id, and duration of the longest trip.
- Id, start station id, and duration of the shortest trips.
- SELECT MAX(duration), id FROM trips;
- SELECT MIN(duration), id FROM trips;
- SELECT ROUND(AVG(dock_count), 2) FROM stations;
- SELECT MAX(dock_count) FROM stations;
- SELECT COUNT(id) FROM conditions WHERE precipitation_inches = 0;
- SELECT name, dock_count FROM stations ORDER BY dock_count DESC LIMIT 1;
- SELECT id, start_station_id, duration FROM trips ORDER BY duration DESC LIMIT 1;
- SELECT id, start_station_id, duration FROM trips ORDER BY duration ASC LIMIT 1;
- # JOIN
- Name of the station where the longest trip started.
- Name of the stations where the shortest trips started.
- SELECT stations.name FROM stations JOIN trips ON stations.id = trips.start_station_id WHERE trips.duration = (SELECT max(trips.duration) FROM trips);
- SELECT stations.name FROM stations JOIN trips ON stations.id = trips.start_station_id WHERE trips.duration = (SELECT min(trips.duration) FROM trips);
- # GROUP
- Count of trips started at each station.
- Count of trips ended at each station.
- Count of trips started on days with more than an inch of precipitation.
- SELECT COUNT(start_station_name) AS trips, start_station_name FROM trips GROUP BY start_station_name ORDER BY trips DESC;
- SELECT COUNT(end_station_name) AS trips, end_station_name FROM trips GROUP BY end_station_name ORDER BY trips DESC;
- SELECT COUNT(trips.start_station_id) AS trips, trips.start_date FROM trips JOIN conditions on trips.start_date = conditions.date WHERE precipitation_inches > 1 GROUP BY trips.start_date;
- # ORDER
- Top five stations with the most trips started.
- Top five stations with the most trips ended.
- Least popular start station.
- mean_temperature and precipiation on the five dates with the most trips.
Add Comment
Please, Sign In to add comment