Guest User

Untitled

a guest
Dec 14th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. SELECT FROM LIMIT
  2.  
  3. All of the information on the stations table. SELECT * FROM stations
  4. Max, min, and mean temp from the conditions table.
  5. SELECT MAX(max_temperature_f) FROM conditions;
  6. SELECT MIN(max_temperature_f) FROM conditions;
  7. SELECT AVG(max_temperature_f) FROM conditions;
  8.  
  9. id, start_station_id, and duration of five trips.
  10. WHERE
  11.  
  12. Trips that started at the station with an id of 2.
  13.  
  14. SELECT id, start_station_id, duration FROM trips WHERE start_station_id = '2'LIMIT 5;
  15.  
  16. Stations that have a dock_count of 15.
  17.  
  18. SELECT * FROM stations WHERE dock_count = '15';
  19.  
  20. id, date, and precipitation for conditions with more than 1 inch of precipitation.
  21.  
  22. SELECT id, date, precipitation_inches FROM conditions WHERE precipitation_inches > '1';
  23.  
  24. max/min/count/average
  25.  
  26. Duration of the longest trip.
  27. SELECT MAX(duration) FROM trips;
  28.  
  29. Duration of the shortest trip.
  30. SELECT MIN(duration) FROM trips;
  31.  
  32. Average dock_count at a station.
  33. SELECT AVG(dock_count) FROM stations;
  34.  
  35. Highest dock_count at a station.
  36. SELECT MAX(duration) FROM trips;
  37. Count of days with no rain.
  38. SELECT COUNT(*) FROM conditions WHERE precipitation_inches = 0;
  39. Name/dock_count of the station with the most docks.
  40. SELECT name, dock_count FROM stations WHERE dock_count = (SELECT MAX(dock_count) FROM stations);
  41.  
  42. Id, start station id, and duration of the longest trip.
  43. SELECT id,start_station_id, duration FROM trips WHERE duration = (SELECT MAX(duration) FROM trips);
  44. Id, start station id, and duration of the shortest trips.
  45. SELECT id,start_station_id, duration FROM trips WHERE duration = (SELECT MIN(duration) FROM trips);
  46. JOIN
  47.  
  48. Name of the station where the longest trip started.
  49.  
  50. SELECT name FROM stations JOIN trips ON stations.id = start_station_id WHERE duration = (SELECT MAX(duration) FROM trips);
  51.  
  52. Name of the stations where the shortest trips started.
  53.  
  54. SELECT name FROM stations JOIN trips ON stations.id = start_station_id WHERE duration = (SELECT MIN(duration) FROM trips);
  55.  
  56. GROUP
  57.  
  58.  
  59. Count of trips started at each station.
  60. Count of trips ended at each station.
  61. Count of trips started on days with more than an inch of precipitation.
  62. ORDER
  63.  
  64. Top five stations with the most trips started.
  65. Top five stations with the most trips ended.
  66. Least popular start station.
  67. mean_temperature and precipiation on the five dates with the most trips.
Add Comment
Please, Sign In to add comment