中级农民
- 积分
- 104
- 大米
- 颗
- 鳄梨
- 个
- 水井
- 尺
- 蓝莓
- 颗
- 萝卜
- 根
- 小米
- 粒
- 学分
- 个
- 注册时间
- 2015-6-17
- 最后登录
- 1970-1-1
|
. From 1point 3acres bbs
Given the below subset of Uber’s schema, write executable SQL queries to answer the questions below.
Please answer in a single query and assume read-only access to the database (i.e. do not use CREATE. .и
TABLE).
Assume a PostgreSQL database, server timezone is UTC.
-baidu 1point3acres
Table Name: trips-baidu 1point3acres
Column Name: Datatype:
id integer-baidu 1point3acres
client_id integer (Foreign keyed to users.user_id)
driver_id integer (Foreign keyed to users.user_id)
city_id integer
client_rating integer
driver_rating integer
status Enum(‘completed’, ‘cancelled_by_driver’, ‘cancelled_by_client’).google и
actual_eta integer
request_at timestamp with timezone
distance float
fare float
. Waral dи,
Table Name: cities
Column Name: Datatype:
city_id integer
name character varying (varchar)
created_at timestamp with timezone
launched_at timestamp with timezone
status Enum(‘active’, ‘launching’, ‘closed’)
country character varying (varchar)
Table Name: users
Column Name: Datatype:
user_id integer
first_name character varying (varchar)-baidu 1point3acres
last_name character varying (varchar)
email character varying (varchar)
signup_city_id integer
banned Boolean. 1point3acres
role Enum(‘client’, ‘driver’, ‘partner’)
created_at timestamp with timezone. Waral dи,
updated_at timestamp with timezone
referral_code character varying (varchar)
referred_by integer (Foreign keyed to users.user_id). ----
deleted_at timestamp with timezone
QUESTIONS
1) In October 2014, how many $15 dollar trips were completed in the United States by day?
What percentage of trips were completed by client who signed up during October 2014?. Χ
2) Identify the 15 most frequent last names for Uber ‘clients’?.google и
3) For city_ids 22, 23, and 35, list the top three clients by average fare per trip (min. 25
completed trips) for the first half of 2012. January 1st - June 30th. Assume the minimum fare is.1point3acres
$12 in all markets.
4) Identify the client and driver/partner with the most referrals in 2013. The query’s output
should display contact information along with the signup_date of their last referral.
5) What is the average client_rating for completed trips in London for early morning (2am -
5am) trips?. 1point 3acres
6) Provide the distribution of drivers by the number of completed trips in 2015. Group these
drivers in the follow three buckets: less than 100 trips, between 100 and 300 trips, more than
300 trips.
7) Of referred clients, what percentage of them completed a trip?-baidu 1point3acres
|
|