注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号
x
本人收集到的SQL 题 with 标准答案 还请大家帮忙加米!不设置任何积分权限!
FB: Popularity Percentage . From 1point 3acres bbs
Find the popularity percentage for each user on FB. the popularity percentage is defined as the total number of friends the user has divide by the total number of users on the platform
--total number of friends the user has/total number of users on the platform
--total number of users on the platform: union user 1 and user 2
--total number of friends the user has: union user1 and user2, user2 and user1
Select user1,count(*)/max(tuu.all_users) *100 from (
Select coin(*) as all_users from (
Select distinct user1 from facebook_friends
Union
Select distinct user2 from facebook_friends) total_unique_users
)tuu. 1point 3acres
Join (
. 1point3acres.com Select user1,user2 from facebook_friends
Union
Select user2 as user1, user1 as user2 from facebook_friends) b
On 1=1
Group by user1
Order by user1 asc
FB: SMS confirmation from users
Fb sends SMS texts when users 2f to logoin at which time they must confirm they received the sms text. Confirmation texts are only valid on the date they were sent. Unfortunately, there was an ETL problem where friend requests and invalid confirmation records were inserted into the fb_sms_sends table. fortunately , the fb_confirmers table contains valid confirmation records.
Calculate pct of confirmed SMS texts for august 4, 2020
--filter out type=confirmation and type=friend request
--filter for ds=’08-04’2020’
--left join fb confirmers with fb-sms sends on phone number
--count(phone numbers from fb_confirms)/count(phone_numers from fb_sms_sends)
Select count(b.phone_number)/count(a.phone_number)*100 as pct from fb_sms_sends a
Left join fb_confirmers b .google и
On a.phone_number=b.phone_number and b.dat21159. 市场分析 II
Table: Users
+----------------+---------+
| Column Name | Type |
+----------------+---------+
| user_id | int |
| join_date | date |
| favorite_brand | varchar |
+----------------+---------+
user_id is the primary key of this table.
. 1point 3 acresThis table has the info of the users of an online shopping website where users can sell and buy items.. check 1point3acres for more.
Table: Orders. Waral dи,
+---------------+---------+
| Column Name | Type |
+---------------+---------+
| order_id | int |
| order_date | date |
| item_id | int |
| buyer_id | int |
. Waral dи,| seller_id | int |-baidu 1point3acres
+---------------+---------+
order_id is the primary key of this table.. 1point 3acres
item_id is a foreign key to the Items table.. check 1point3acres for more.
buyer_id and seller_id are foreign keys to the Users table.
Table: Items
+---------------+---------+
.google и
. From 1point 3acres bbs
|