Twitch数据科学家手把手教你拿下面试必考的SQL
SELECT
FROM
JOIN
WHERE
(AND)
GROUP BY
ORDER BY
LIMIT
SELECT username, count(1) as number_of_views
FROM pageviews
WHERE day = '2017-09-08'
GROUP BY username
ORDER BY username;
SELECT store_id, zipcode, revenue
FROM stores as s
WHERE revenue >=
(SELECT Avg(revenue)
FROM stores
WHERE s.zipcode = stores.zipcode)
ORDER BY zipcode;
-- 首先,找出2017年9月8日所有user_a的交易记录
with user_a_trans as (
SELECT username, time
FROM transactions
WHERE day = '2017-09-08'
AND username = 'user_a'),
-- 将每一条交易与在它之后发生的所有交易合并在一张表格里
joined_trans as (
SELECT username, time, future_times
FROM user_a_trans a
INNER JOIN user_a_trans b
ON b.time > a.time),
-- 使用MIN()函数找出最近的下一次交易
next_trans as (
SELECT username, time, MIN(future_times) as next_time
FROM joined_trans
GROUP BY username, time)
-- 将前一次交易与下一次交易的时间差取平均值
SELECT AVG(next_time - time) as avg_time_to_next_transactionfrom next_trans;
SELECT *
FROM table_a a
INNER JOIN table_b b
ON a.username = b.username
WHERE a.day >= '2017-09-01'
with a as (
SELECT *
FROM table_a
WHERE day >= '2017-09-01'),
b as (
SELECT *
FROM table_b
WHERE day >= '2017-09-01')
SELECT *
FROM a
INNER JOIN b
ON a.username=b.username;
with state_totals as (
SELECT state, revenue,
SUM(revenue) OVER (PARTITION BY state) as state_revenue
FROM state_line_items)
SELECT state,
revenue/state_revenue as percent_of_state_revenue
FROM state_totals;
Union及Case语句
with sales as (
SELECT 'sale' as type
FROM sale_transactions
WHERE day >= '2017-09-01'),
buys as (
SELECT 'buy' as type
FROM buy_transactions
WHERE day >= '2017-09-01'),
unioned as (
SELECT type
FROM buys
UNION ALL
SELECT type
FROM sales)
SELECT type, count(1) as num_transactions
FROM unioned
GROUP BY type;
SELECT
CASE WHEN day_of_week in ('Sat', 'Sun')
then 'Weekend' else 'Weekday' end as day_type
FROM table_a;
SELECT
SUM(
CASE WHEN day_of_week in ('Sat', 'Sun')
THEN 1 ELSE 0 END) as num_weekend_days
FROM table_a;
Amazon专家授课 + 在线集中答疑 = 拿下你的下一场SQL面试!
MarTechApe联合亚马逊商务智能工程师(Amazon Business Intelligence Engineer)—— Cindy老师,开设了SQL特训课,将行业内所需SQL技能和面试考点浓缩成6个小时的课程内容,让你短时间就能实现SQL能力质的飞跃!
前3小时全方面提升你的SQL能力,用SQL完成一系列的数据分析操练,真正学会SQL编程语言,而不是“只知道个大概”。 后3小时深入辅导Google、Facebook、Amazon、Apple、Uber、Airbnb等知名公司的SQL面试真题,总结不同公司的SQL出题风格。让你从此不再胆怯SQL面试题! 2小时在线集中答疑、模拟面试,并分享SQL在线面试(Live SQL Interview)与白板编程(white board coding)面试技巧。
报名成功的同学还可获赠一场Cindy老师的《如何成为亚马逊Business Intelligence商务智能分析师》线上讲座。
课程大纲
Introduction to SQL | SQL基本概念
SQL introduction, basic concept of relational database
SQL usage in work, transactional database, analysis database
SQL generations:
Oracle
SQL Server
MySQL
Postgres
Redshift
Basic SQL | 1小时SQL基本语句与功能应用
Basic SQL -1:
SELECT
LIMIT
WHERE
Basic SQL -2: Comparison
LIKE
IN
BETWEEN
IS NULL
Basic SQL -3:
Boolean ( AND, OR, NOT)
ORDER BY
Basic SQL -4:
Aggregation ( COUNT, SUM, MIN, MAX, AVG),
GROUP BY
Basic SQL -5:
HAVING
DISTINCT
Basic SQL -6: Case
Intermediate SQL | 2小时SQL进阶语句与功能应用
Intermediate SQL -1: Joins
NNER
OUTER
LEFT
RIGHT
JOIN USING WHERE or ON
Intermediate SQL -2:
UNION
JOIN with comparison
JOIN on multi-key, self join
Intermediate SQL -3:
Data types
Data format
String function
Window function
Intermediate SQL -4:
Primary key
Index
Sort key
Distribution key
SQL Interview Questions | 3小时SQL面试真题详解
Deep dive into SQL interview questions from major Tech companies including but not limited to:
Google
Amazon
Apple
Facebook
Cracking the SQL Interviews | 2小时SQL模拟面试、答疑、面试经验分享
Live Q&A
Interview tips on SQL online Test (e.g., Live interview, CoderPad)
SQL challenges in the real business world
Amazon亚马逊美国担任商务智能工程师(Business Intelligence Engineer) 亚马逊SQL面试官
课程形式
3小时SQL系统性知识培训 + 3小时SQL真题详解+2小时线上答疑模拟面试 录播课程+直播答疑,所有内容均有视频回放,一经购买,可永久回看。 专属课程学习小组,持续SQL真题讨论、学习经验分享。
只购买3小时SQL系统性知识培训:149美元/人
只购买3小时SQL真题特训:149美元/人
购买6小时全套课程:249美元/人
想要快速提高你的SQL能力,就快来报名吧!
坚持学习,保持职场竞争力,选择MarTechApe!
前往“发现”-“看一看”浏览“朋友在看”