Notes by Louisa
Notes by Louisa
Notes by Louisa
  • Introduction
  • Chapter1 Python Cheatsheet
    • Reference, Deep Copy and Shallow Copy
    • Iterators
    • List Comprehensions
    • Numpy
    • Pandas
    • Data Visualization
    • DateTime
    • Python Good to knows
  • Chapter2 Java Cheatsheet
    • Fundamentals to Java
    • Interface, Abstract Class, Access Modifier, Exceptions
    • Linked List and Java List
    • Java Queue, Stack and Deque
    • Binary Tree
    • Heap in Java
    • Map/Set/Hash
    • OOD
  • Chapter3 Algorithm
    • Fundamental Knowledge
    • Binary Search
    • Basic Sorting
    • Advanced Sorting
    • Linked List
    • Recursion 1
    • HashTable
    • Queue
    • Sliding Window
    • Stack
    • Binary Tree
    • Binary Search Tree
    • Heap
    • String
    • Graph Search DFS1 (Back Tracking)
    • Recursion II and Memoization
    • Dynamic Programming
    • Complete Binary Tree, Segment Tree, Trie Tree
    • Graph Search BFS
    • Graph Search BFS 2
    • Graph Search DFS2
    • Problems from 'JianZhi Offer'
    • Problems Categorized
    • Bit Operations
  • Chapter4 Model
    • Linear Regression
    • Logistic Regression
    • Regularization and Feature Selection
    • Model Evaluation
    • Nonlinear Models
    • PCA
    • Unsupervised Learning
    • Gradient Descent and Gradient Boosting
    • XG Boost and Light GBD
    • Deep Learning
    • Tensorflow/Keras
    • RNN
  • Chapter5 Statistics and A/B Testing
    • Inference about independence
    • Probability, Sampling and Randomization with Python
    • A/B Testing
    • Stats Interview Review
    • Statistics Glossary
  • Chapter6 SQL
    • Student Scores Query
    • Order Query
    • Movie Rating Query
    • Social-Network Query
    • LeetCode SQL题目总结
    • Spark SQL
  • Chapter7 Big Data and Spark
    • Introduction to Pyspark
    • Data Cleaning with Apache Spark
    • Feature Engineering with Pyspark
    • Building Recommendation Engines with Pyspark
    • Building Data Engineering Pipelines in Python
    • Hadoop MapReduce
    • Big Data Related Paper
  • Chapter8 Code Walk-Throughs
    • Python
    • R
    • Shell
  • Chapter9 Special Topics
    • Anomaly Detection
    • E Commerce
    • Supply Chain
    • Social Network Analysis
    • NLP intro
    • Time Series
    • Challenge Prophet with LSTM models
  • Project: The Winning Recipes to an Oscar Award
  • Project: A Crime Analysis of the Last Decade NYC
  • Project: Predict User Type Based on Citibike Data
  • GeoSpark/GeoSparkVis for Geospatial Big Data
  • Single Scattering Albedo
  • Sea Ice Albedo Retrievals
  • Lidar Project
Powered by GitBook
On this page
  1. Chapter6 SQL

Movie Rating Query

movie

mid

title

year

director

reviewer

rid

name

rating

rid

mid

stars

ratingdate

#Q1: Find the titles of all movies directed by steven spieberg
SELECT DISTINCT title
FROM movie
WHERE director='Steven Spielberg'
# 注意 like有时候可能是case sensitive 
# 如果是两个数值,可以用 IN(,)

#Q2 Find all rating years that have a movie that received a rating of 4/5, and sort them in increasing order
SELECT a.year, b.stars
FROM 

#Q3 titles of all movies that have no ratings
SELECT titles
FROM movie
LEFT JOIN rating 
ON movie.id=rating.id
WHERE star is null

#Q4 Find the names of all reviewers who have ratings with a null
SELECT a.name
FROM reviewer a
INNER JOIN rating b
USING rid
WHERE b.stars is null

#Q5 For all cases where the same reviewer rated the same movie twice ONLY
# and gave it a higher rating the second time, return the reviewers name and the title of the movie. 
# 先找到rate2次的人,再在这个table里找到第二次多于第一次的

#Q6 movie at least 1 rating, highest number of stars it received, sort by movie table
SELECT a.title, max(b.stars)
FROM movie a
JOIN rating b
ON a.mid=b.mid
WHERE b.stars is not null
GROUP BY 1
ORDER BY 1

#Q7 find range of rating 

#Q8 难得的需要笛卡尔乘积的

FROM (SELECT a.movie,

PreviousOrder QueryNextSocial-Network Query

Last updated 5 years ago