-
Notifications
You must be signed in to change notification settings - Fork 0
/
Data_Analysis_using_SQL.py
43 lines (31 loc) · 1.02 KB
/
Data_Analysis_using_SQL.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Databricks notebook source
# MAGIC %md
# MAGIC ####Create table using parquet file
# COMMAND ----------
# MAGIC %sql
# MAGIC CREATE TABLE basketball_silver
# MAGIC USING parquet
# MAGIC OPTIONS (path "/FileStore/cleansed_data.parquet")
# COMMAND ----------
# MAGIC %sql
# MAGIC select * from basketball_silver
# COMMAND ----------
# MAGIC %md
# MAGIC #####1. View most aged players from each team
# COMMAND ----------
# MAGIC %sql
# MAGIC with cte as (
# MAGIC select name, team, age,row_number() over (partition by team order by age desc) as rnum
# MAGIC from basketball_silver)
# MAGIC select name,team,age from cte
# MAGIC where rnum=1
# COMMAND ----------
# MAGIC %md
# MAGIC #####2. Display player from each team with height greater than 6 feet.
# COMMAND ----------
# MAGIC %sql
# MAGIC with cte as (
# MAGIC select name, team, height,feet, row_number() over (partition by team order by height desc) as rnum
# MAGIC from basketball_silver where height>72)
# MAGIC select name,team,height,feet from cte
# MAGIC where rnum=1