Skip to content

Commit

Permalink
Assignment done
Browse files Browse the repository at this point in the history
  • Loading branch information
shuaiwo committed Feb 12, 2024
1 parent 0ebb03c commit 8821fa8
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 10 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_NAME=musa_509
POSTGRES_NAME=musaw3
POSTGRES_USER=postgres
POSTGRES_PASS=postgres
2 changes: 1 addition & 1 deletion assingment 1.pgsql
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ select *
from indego.trips_2021_q3

SELECT * FROM indego.trips_2021_q3 LIMIT 10;

SELECT * FROM indego.station_statuses LIMIT 10;

alter table indego.stations
alter column go_live_date type date
Expand Down
11 changes: 8 additions & 3 deletions query02.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@
-- Enter your SQL query here

select
(100*((select count(*) from indego.trips_2022_q3) -
(select count(*) from indego.trips_2021_q3)) /
((select count(*) from indego.trips_2021_q3)))
round(
100 * (
(select count(*) from indego.trips_2022_q3) -
(select count(*) from indego.trips_2021_q3)
) ::numeric /
(select count(*) from indego.trips_2021_q3), 2)
::text || '%' AS perc_change




/*
If you want to get fancier here, you can cast the result to a string and
concatenate a '%' to the end. For example:
Expand Down
2 changes: 1 addition & 1 deletion query03.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@

-- Enter your SQL query here

SELECT ROUND(AVG(duration), 2)
SELECT ROUND(AVG(duration), 2) as avg_duration
FROM indego.trips_2021_q3;
2 changes: 1 addition & 1 deletion query04.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@

-- Enter your SQL query here

SELECT ROUND(AVG(duration), 2)
SELECT ROUND(AVG(duration), 2) as avg_duration
FROM indego.trips_2022_q3;
2 changes: 1 addition & 1 deletion query05.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

-- Enter your SQL query here

SELECT MAX(duration)
SELECT MAX(duration) as max_duration
FROM indego.trips_2021_q3 UNION SELECT MAX(duration)
FROM indego.trips_2022_q3;
4 changes: 2 additions & 2 deletions query08.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
SELECT
start_station AS station_id,
st_setsrid(
ST_MakePoint(start_lat, start_lon), 4326)::geography
ST_MakePoint(start_lon, start_lat), 4326)
AS station_geog,
COUNT(*) AS num_trips
FROM
Expand All @@ -24,7 +24,7 @@ WHERE
EXTRACT(HOUR FROM start_time) >= 7 AND
EXTRACT(HOUR FROM start_time) < 10
GROUP BY
station_id, station_geog
start_station, start_lon, start_lat
ORDER BY
num_trips DESC
LIMIT 5;
Expand Down

0 comments on commit 8821fa8

Please sign in to comment.