注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
本人收集到的SQL 题 with 标准答案 还请大家帮忙加米!不设置任何积分权限!
FB: Popularity Percentage . .и
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.google и
Select distinct user2 from facebook_friends) total_unique_users
)tuu
Join ( ..
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 typ21159. 市场分析 II
Table: Users
+----------------+---------+
| Column Name | Type |. 1point3acres
+----------------+---------+. .и
| user_id | int |
| join_date | date |
| favorite_brand | varchar |-baidu 1point3acres
+----------------+---------+
user_id is the primary key of this table.
This table has the info of the users of an online shopping website where users can sell and buy items.
Table: Orders
+---------------+---------+
| Column Name | Type |.
+---------------+---------+
| order_id | int |. .и
| order_date | date |
| item_id | int |
| buyer_id | int |
| seller_id | int |
+---------------+---------+
order_id is the primary key of this table.
item_id is a foreign key to the Items table.
buyer_id and seller_id are foreign keys to the Users table.
Table: Items
+---------------+---------+
. From 1point 3acres bbs
.
|