SlideShare ist ein Scribd-Unternehmen logo
1 von 29
Downloaden Sie, um offline zu lesen
Welcome
For Data Scientists
Advanced SQL
Jean Joseph
Data Engineer/DBA
Blog : bigdatadriven.org
Email: jean.joseph@bigdatadriven.org
Twitter: @garella79/@cloudatadriven
LinkedIn: https://www.linkedin.com/in/jeandjoseph/
In IT: For over 18 plus years
From: New Jersey
Original From: Haiti
Overview
Brief intro to SQL. The five major things to
know in RDBMS
Data preparation in
SQL SQL advanced filtering
preparing data for use
with analytics tools
Key takeaways
What is
RDBMS?
• Relational Data Management System
• Tabular
• Row(s), Colum(s)
• Objects (Tables, Views, Synonyms,
Functions, Procedures,..)
• Normalization – (OLTP)
• De-Normalization (OLAP)
• ACID
What Is SQL?
• Stand for Query Structure Language
• SQL lets you Control, Create, Modify
object(s) and manipulate data
What
Can We
Do With
SQL?
DDL
CREATE, DROP, TRUNCATE, ALTER, COMMENT, RENAME
DQL
SELECT
DML INSERT, UPDATE, DELETE
DCL GRANT, REVOKE
TCL
COMMIT, ROLLBACK, SAVEPOINT, SET
Why SQL?
CRUD
Data Scientist Should Master
Type Of SQL
Joins
APPLY (Transact-SQL).
• CROSS
• OUTTER
PIVOT (Transact-SQL).
UNION [ALL]
EXCEPT
INTERCECT
Join Data Set
Data Preparation
COLLECTING DATA CLEANING DATA RE-STRUCTING DATA
Position Character Set
Transformation Soundex
SQL Functions To Prep Data
• CHARINDEX
• PATINDEX
• LEN
• STUFF
• STRING_AGG
• SUBSTRING.
• STRING_SPLIT
• STRING_ESCAPE
• TRANSLATE
• CONCAT_WS
• CONCAT
• LEFT
• RIGHT
• LOWER
• UPPER
• LEN
• TRIM
• REPLACE
• REVERSE
• REPLICATE
• ASCII
• CHAR
• NCHAR
• UNICODE
• DIFFERENCE
• SOUNDEX
SQL Functions To Prep Data
AGGREGATE vs WINDOWING FUNCTIONS
AGGREGATE FUNCTIONS:
• which operate on an entire data set or table and are used with a GROUP BY clause.
WINDOWING FUNCTIONS:
• do not cause rows to become grouped into a single output row, the rows retain their
separate identities an aggregated value will be added to each row.
Types of Window functions:
• Aggregate Window Functions
• SUM(), MAX(), MIN(), AVG(). COUNT()
• Ranking Window Functions
• RANK(), DENSE_RANK(), ROW_NUMBER(),
NTILE()
• Value Window Functions
• LAG(), LEAD(), FIRST_VALUE(), LAST_VALUE()
WINDOW_FUNCTION ( [ ALL ] expression )
OVER ( [ PARTITION BY partition_list ]
[ ORDER BY order_list] )
Demo
Preparing Data Using SQL
CHARINDEX ( expressionToFind ,
expressionToSearch
[ , start_location ]
)
Data Prep Position Function - CHARINDEX
String: This is a great event
Parameter Description
string Required. The string to extract from
start
Required. The start position. The
first position in string is 1
length
Required. The number of characters
to extract. Must be a positive
number
SUBSTRING(string, start, length)
Data Prep Position Function
PATINDEX
PATINDEX ( '%pattern%' , expression )
%pattern% Required. The pattern to find. It MUST be surrounded
by %.
• % - Match any string of any length (including 0 length)
• _ - Match one single character
• [] - Match any characters in the brackets, e.g. [xyz]
• [^] - Match any character not in the brackets, e.g. [^xyz]
• | | string | Required. The string to be searched |
Find any string that contain
big, and end with driven.org'
Data Prep Position Function - TRING_AGG
STRING_AGG ( input_string, separator ) [ order_clause ]
v input_string is any type that can be converted VARCHAR and NVARCHAR when
concatenation.
v separator is the separator for the result string. It can be a literal or variable.
v order_clause specifies the sort order of concatenated results using WITHIN
GROUP clause:
WITHIN GROUP ( ORDER BY expression [ ASC | DESC ] )
Data Prep Position Function - STRING_SPLIT
STRING_SPLIT(string, separator)
Analytic
• CUME_DIST (Transact-SQL)
• FIRST_VALUE (Transact-SQL)
• LAG (Transact-SQL)
• LAST_VALUE (Transact-SQL)
• LEAD (Transact-SQL)
• PERCENT_RANK (Transact-SQL)
• PERCENTILE_CONT (Transact-SQL)
• PERCENTILE_DISC (Transact-SQL)
Aggregate
• APPROX_COUNT_DISTINCT()
• AVG ()
• CHECKSUM_AGG ()
• COUNT ()
• COUNT_BIG ()
• GROUPING ()
• GROUPING_ID
• MAX ()
• MIN ()
• STDEV ()
• STDEVP ()
• SUM ()
• VAR ()
• VARP ()
Windowing Function – Framing
• Rows/Range
• Rows is in memory
• Range is in Tempdb
• Keywords
• Preceding
• Following
• Unbounded
• Current
• Ranking
• ROW_NUMBER()
• RANK()
• DENSE_RANK
• NTILE
SQLAggregate & Analytical Functions
Demo
SQLAggregate & Analytical
Business Request:
Provide the Total sales Due, Total Average Sales Orders, Total
Number of Sales Orders and Total Sales Rank
Orders for each year including all fees (Tax, Shipping, ..).
Task:
• Get all sales orders for each year
• To calculate the
• Sum of Total Due by Year.
• Total AVG of Sales Orders by Year.
• Total Number of Sales Orders by Year.
• How well products are selling relative to other years.
Hint: Each year --> GROUP BY (AGGREGATE FUNCTIONS)
Business Request: RUNNING TOTAL
Ø Provide the Daily Running Total Due on
Sales Orders and include CustomerID,
SalesOrderID, OrderDate for the period
of 2014-06-01 onward.
Ø Order by SalesOrderID, OrderDate
Business Request:
The Marketing Team has asked you to return
the first three (3) orders, plus the close price,
Total Order Due, Total Orders for every
customer that purchased more than 15 times
from us.
Tasks:
q Find all orders details per customer
q return only the first 3 orders per customer
with:
ü Close Price
ü Total Orders
ü where Total Order Counts is greater
than 15
Business User has asked you to return all orders from the
SalesOrderHeader table for any customer who had over
$10.000 in purchases for their first three transactions
Task:
Ø Find the first three orders per customer
Ø Aggregate the first three orders
Ø Return all orders for those customers
Ø Return all customers with over $10.000
Business Request:
Find the summary of the first and last close price for each day of every months of the year including every
single details.
Business wants this display
To be like this format
Calculate the total due for each month, and get the subtotal for each
year by region and territory.
The Five Major Things To know In
RDBMS
• CRUD
• ACID
• TCL
• Query Optimizer
• When To Use Index
Bonus
• Exception
Key
Takeaways
Deep understanding of ACID.
Master DQL & DML Command.
Know when to use TCL Command
Feedback
Your feedback is important to us.
Don’t forget to rate and review
the sessions.
Jean Joseph
Data Engineer/DBA
Blog : bigdatadriven.org
Email: jean.joseph@bigdatadriven.org
Twitter: @garella79/@cloudatadriven
Thank You So much For Your
Participation!

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

MongoDB vs. Postgres Benchmarks
MongoDB vs. Postgres Benchmarks MongoDB vs. Postgres Benchmarks
MongoDB vs. Postgres Benchmarks
 
PostgreSQL Tutorial for Beginners | Edureka
PostgreSQL Tutorial for Beginners | EdurekaPostgreSQL Tutorial for Beginners | Edureka
PostgreSQL Tutorial for Beginners | Edureka
 
Is the traditional data warehouse dead?
Is the traditional data warehouse dead?Is the traditional data warehouse dead?
Is the traditional data warehouse dead?
 
Real-Time Data Flows with Apache NiFi
Real-Time Data Flows with Apache NiFiReal-Time Data Flows with Apache NiFi
Real-Time Data Flows with Apache NiFi
 
NoSQL databases
NoSQL databasesNoSQL databases
NoSQL databases
 
Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...
Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...
Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...
 
Introduction to PySpark
Introduction to PySparkIntroduction to PySpark
Introduction to PySpark
 
MongoDB at Scale
MongoDB at ScaleMongoDB at Scale
MongoDB at Scale
 
Hadoop with Python
Hadoop with PythonHadoop with Python
Hadoop with Python
 
Introduction to Amazon Redshift
Introduction to Amazon RedshiftIntroduction to Amazon Redshift
Introduction to Amazon Redshift
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
PostgreSQL
PostgreSQLPostgreSQL
PostgreSQL
 
Introduction to NoSQL
Introduction to NoSQLIntroduction to NoSQL
Introduction to NoSQL
 
Oracle Performance Tools of the Trade
Oracle Performance Tools of the TradeOracle Performance Tools of the Trade
Oracle Performance Tools of the Trade
 
How to understand and analyze Apache Hive query execution plan for performanc...
How to understand and analyze Apache Hive query execution plan for performanc...How to understand and analyze Apache Hive query execution plan for performanc...
How to understand and analyze Apache Hive query execution plan for performanc...
 
Introduction to Pandas and Time Series Analysis [PyCon DE]
Introduction to Pandas and Time Series Analysis [PyCon DE]Introduction to Pandas and Time Series Analysis [PyCon DE]
Introduction to Pandas and Time Series Analysis [PyCon DE]
 
PostgreSQL Tutorial For Beginners | Edureka
PostgreSQL Tutorial For Beginners | EdurekaPostgreSQL Tutorial For Beginners | Edureka
PostgreSQL Tutorial For Beginners | Edureka
 
Elasticsearch
ElasticsearchElasticsearch
Elasticsearch
 
Intro to Neo4j and Graph Databases
Intro to Neo4j and Graph DatabasesIntro to Neo4j and Graph Databases
Intro to Neo4j and Graph Databases
 
MongoDB performance
MongoDB performanceMongoDB performance
MongoDB performance
 

Ähnlich wie Advanced SQL For Data Scientists

Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence Portfolio
Chris Seebacher
 

Ähnlich wie Advanced SQL For Data Scientists (20)

Simplifying SQL with CTE's and windowing functions
Simplifying SQL with CTE's and windowing functionsSimplifying SQL with CTE's and windowing functions
Simplifying SQL with CTE's and windowing functions
 
Exploring Advanced SQL Techniques Using Analytic Functions
Exploring Advanced SQL Techniques Using Analytic FunctionsExploring Advanced SQL Techniques Using Analytic Functions
Exploring Advanced SQL Techniques Using Analytic Functions
 
Exploring Advanced SQL Techniques Using Analytic Functions
Exploring Advanced SQL Techniques Using Analytic FunctionsExploring Advanced SQL Techniques Using Analytic Functions
Exploring Advanced SQL Techniques Using Analytic Functions
 
SQL Windowing
SQL WindowingSQL Windowing
SQL Windowing
 
SFDC Advanced Apex
SFDC Advanced Apex SFDC Advanced Apex
SFDC Advanced Apex
 
In memory databases presentation
In memory databases presentationIn memory databases presentation
In memory databases presentation
 
Oracle Advanced SQL and Analytic Functions
Oracle Advanced SQL and Analytic FunctionsOracle Advanced SQL and Analytic Functions
Oracle Advanced SQL and Analytic Functions
 
Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence Portfolio
 
Presentation interpreting execution plans for sql statements
Presentation    interpreting execution plans for sql statementsPresentation    interpreting execution plans for sql statements
Presentation interpreting execution plans for sql statements
 
Explaining the explain_plan
Explaining the explain_planExplaining the explain_plan
Explaining the explain_plan
 
Oracle APEX Cheat Sheet
Oracle APEX Cheat SheetOracle APEX Cheat Sheet
Oracle APEX Cheat Sheet
 
20180420 hk-the powerofmysql8
20180420 hk-the powerofmysql820180420 hk-the powerofmysql8
20180420 hk-the powerofmysql8
 
Query optimizer vivek sharma
Query optimizer vivek sharmaQuery optimizer vivek sharma
Query optimizer vivek sharma
 
Love Your Database Railsconf 2017
Love Your Database Railsconf 2017Love Your Database Railsconf 2017
Love Your Database Railsconf 2017
 
R programming & Machine Learning
R programming & Machine LearningR programming & Machine Learning
R programming & Machine Learning
 
Run your queries 14X faster without any investment!
Run your queries 14X faster without any investment!Run your queries 14X faster without any investment!
Run your queries 14X faster without any investment!
 
The art of querying – newest and advanced SQL techniques
The art of querying – newest and advanced SQL techniquesThe art of querying – newest and advanced SQL techniques
The art of querying – newest and advanced SQL techniques
 
Enabling Applications with Informix' new OLAP functionality
 Enabling Applications with Informix' new OLAP functionality Enabling Applications with Informix' new OLAP functionality
Enabling Applications with Informix' new OLAP functionality
 
Scaling PostgreSQL With GridSQL
Scaling PostgreSQL With GridSQLScaling PostgreSQL With GridSQL
Scaling PostgreSQL With GridSQL
 
3 CityNetConf - sql+c#=u-sql
3 CityNetConf - sql+c#=u-sql3 CityNetConf - sql+c#=u-sql
3 CityNetConf - sql+c#=u-sql
 

Mehr von Databricks

Democratizing Data Quality Through a Centralized Platform
Democratizing Data Quality Through a Centralized PlatformDemocratizing Data Quality Through a Centralized Platform
Democratizing Data Quality Through a Centralized Platform
Databricks
 
Stage Level Scheduling Improving Big Data and AI Integration
Stage Level Scheduling Improving Big Data and AI IntegrationStage Level Scheduling Improving Big Data and AI Integration
Stage Level Scheduling Improving Big Data and AI Integration
Databricks
 
Simplify Data Conversion from Spark to TensorFlow and PyTorch
Simplify Data Conversion from Spark to TensorFlow and PyTorchSimplify Data Conversion from Spark to TensorFlow and PyTorch
Simplify Data Conversion from Spark to TensorFlow and PyTorch
Databricks
 
Raven: End-to-end Optimization of ML Prediction Queries
Raven: End-to-end Optimization of ML Prediction QueriesRaven: End-to-end Optimization of ML Prediction Queries
Raven: End-to-end Optimization of ML Prediction Queries
Databricks
 
Processing Large Datasets for ADAS Applications using Apache Spark
Processing Large Datasets for ADAS Applications using Apache SparkProcessing Large Datasets for ADAS Applications using Apache Spark
Processing Large Datasets for ADAS Applications using Apache Spark
Databricks
 

Mehr von Databricks (20)

DW Migration Webinar-March 2022.pptx
DW Migration Webinar-March 2022.pptxDW Migration Webinar-March 2022.pptx
DW Migration Webinar-March 2022.pptx
 
Data Lakehouse Symposium | Day 1 | Part 1
Data Lakehouse Symposium | Day 1 | Part 1Data Lakehouse Symposium | Day 1 | Part 1
Data Lakehouse Symposium | Day 1 | Part 1
 
Data Lakehouse Symposium | Day 1 | Part 2
Data Lakehouse Symposium | Day 1 | Part 2Data Lakehouse Symposium | Day 1 | Part 2
Data Lakehouse Symposium | Day 1 | Part 2
 
Data Lakehouse Symposium | Day 2
Data Lakehouse Symposium | Day 2Data Lakehouse Symposium | Day 2
Data Lakehouse Symposium | Day 2
 
Data Lakehouse Symposium | Day 4
Data Lakehouse Symposium | Day 4Data Lakehouse Symposium | Day 4
Data Lakehouse Symposium | Day 4
 
5 Critical Steps to Clean Your Data Swamp When Migrating Off of Hadoop
5 Critical Steps to Clean Your Data Swamp When Migrating Off of Hadoop5 Critical Steps to Clean Your Data Swamp When Migrating Off of Hadoop
5 Critical Steps to Clean Your Data Swamp When Migrating Off of Hadoop
 
Democratizing Data Quality Through a Centralized Platform
Democratizing Data Quality Through a Centralized PlatformDemocratizing Data Quality Through a Centralized Platform
Democratizing Data Quality Through a Centralized Platform
 
Learn to Use Databricks for Data Science
Learn to Use Databricks for Data ScienceLearn to Use Databricks for Data Science
Learn to Use Databricks for Data Science
 
Why APM Is Not the Same As ML Monitoring
Why APM Is Not the Same As ML MonitoringWhy APM Is Not the Same As ML Monitoring
Why APM Is Not the Same As ML Monitoring
 
The Function, the Context, and the Data—Enabling ML Ops at Stitch Fix
The Function, the Context, and the Data—Enabling ML Ops at Stitch FixThe Function, the Context, and the Data—Enabling ML Ops at Stitch Fix
The Function, the Context, and the Data—Enabling ML Ops at Stitch Fix
 
Stage Level Scheduling Improving Big Data and AI Integration
Stage Level Scheduling Improving Big Data and AI IntegrationStage Level Scheduling Improving Big Data and AI Integration
Stage Level Scheduling Improving Big Data and AI Integration
 
Simplify Data Conversion from Spark to TensorFlow and PyTorch
Simplify Data Conversion from Spark to TensorFlow and PyTorchSimplify Data Conversion from Spark to TensorFlow and PyTorch
Simplify Data Conversion from Spark to TensorFlow and PyTorch
 
Scaling your Data Pipelines with Apache Spark on Kubernetes
Scaling your Data Pipelines with Apache Spark on KubernetesScaling your Data Pipelines with Apache Spark on Kubernetes
Scaling your Data Pipelines with Apache Spark on Kubernetes
 
Scaling and Unifying SciKit Learn and Apache Spark Pipelines
Scaling and Unifying SciKit Learn and Apache Spark PipelinesScaling and Unifying SciKit Learn and Apache Spark Pipelines
Scaling and Unifying SciKit Learn and Apache Spark Pipelines
 
Sawtooth Windows for Feature Aggregations
Sawtooth Windows for Feature AggregationsSawtooth Windows for Feature Aggregations
Sawtooth Windows for Feature Aggregations
 
Redis + Apache Spark = Swiss Army Knife Meets Kitchen Sink
Redis + Apache Spark = Swiss Army Knife Meets Kitchen SinkRedis + Apache Spark = Swiss Army Knife Meets Kitchen Sink
Redis + Apache Spark = Swiss Army Knife Meets Kitchen Sink
 
Re-imagine Data Monitoring with whylogs and Spark
Re-imagine Data Monitoring with whylogs and SparkRe-imagine Data Monitoring with whylogs and Spark
Re-imagine Data Monitoring with whylogs and Spark
 
Raven: End-to-end Optimization of ML Prediction Queries
Raven: End-to-end Optimization of ML Prediction QueriesRaven: End-to-end Optimization of ML Prediction Queries
Raven: End-to-end Optimization of ML Prediction Queries
 
Processing Large Datasets for ADAS Applications using Apache Spark
Processing Large Datasets for ADAS Applications using Apache SparkProcessing Large Datasets for ADAS Applications using Apache Spark
Processing Large Datasets for ADAS Applications using Apache Spark
 
Massive Data Processing in Adobe Using Delta Lake
Massive Data Processing in Adobe Using Delta LakeMassive Data Processing in Adobe Using Delta Lake
Massive Data Processing in Adobe Using Delta Lake
 

Kürzlich hochgeladen

Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Riyadh +966572737505 get cytotec
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
amitlee9823
 
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
amitlee9823
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
amitlee9823
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
amitlee9823
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
amitlee9823
 

Kürzlich hochgeladen (20)

Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFx
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysis
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFx
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
 
Predicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science ProjectPredicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science Project
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
 
ELKO dropshipping via API with DroFx.pptx
ELKO dropshipping via API with DroFx.pptxELKO dropshipping via API with DroFx.pptx
ELKO dropshipping via API with DroFx.pptx
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptx
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
ALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptxALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptx
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptx
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
 

Advanced SQL For Data Scientists

  • 3. Jean Joseph Data Engineer/DBA Blog : bigdatadriven.org Email: jean.joseph@bigdatadriven.org Twitter: @garella79/@cloudatadriven LinkedIn: https://www.linkedin.com/in/jeandjoseph/ In IT: For over 18 plus years From: New Jersey Original From: Haiti
  • 4. Overview Brief intro to SQL. The five major things to know in RDBMS Data preparation in SQL SQL advanced filtering preparing data for use with analytics tools Key takeaways
  • 5. What is RDBMS? • Relational Data Management System • Tabular • Row(s), Colum(s) • Objects (Tables, Views, Synonyms, Functions, Procedures,..) • Normalization – (OLTP) • De-Normalization (OLAP) • ACID
  • 6. What Is SQL? • Stand for Query Structure Language • SQL lets you Control, Create, Modify object(s) and manipulate data What Can We Do With SQL? DDL CREATE, DROP, TRUNCATE, ALTER, COMMENT, RENAME DQL SELECT DML INSERT, UPDATE, DELETE DCL GRANT, REVOKE TCL COMMIT, ROLLBACK, SAVEPOINT, SET Why SQL? CRUD Data Scientist Should Master
  • 7. Type Of SQL Joins APPLY (Transact-SQL). • CROSS • OUTTER PIVOT (Transact-SQL). UNION [ALL] EXCEPT INTERCECT Join Data Set
  • 8. Data Preparation COLLECTING DATA CLEANING DATA RE-STRUCTING DATA
  • 9. Position Character Set Transformation Soundex SQL Functions To Prep Data • CHARINDEX • PATINDEX • LEN • STUFF • STRING_AGG • SUBSTRING. • STRING_SPLIT • STRING_ESCAPE • TRANSLATE • CONCAT_WS • CONCAT • LEFT • RIGHT • LOWER • UPPER • LEN • TRIM • REPLACE • REVERSE • REPLICATE • ASCII • CHAR • NCHAR • UNICODE • DIFFERENCE • SOUNDEX SQL Functions To Prep Data
  • 10. AGGREGATE vs WINDOWING FUNCTIONS AGGREGATE FUNCTIONS: • which operate on an entire data set or table and are used with a GROUP BY clause. WINDOWING FUNCTIONS: • do not cause rows to become grouped into a single output row, the rows retain their separate identities an aggregated value will be added to each row. Types of Window functions: • Aggregate Window Functions • SUM(), MAX(), MIN(), AVG(). COUNT() • Ranking Window Functions • RANK(), DENSE_RANK(), ROW_NUMBER(), NTILE() • Value Window Functions • LAG(), LEAD(), FIRST_VALUE(), LAST_VALUE() WINDOW_FUNCTION ( [ ALL ] expression ) OVER ( [ PARTITION BY partition_list ] [ ORDER BY order_list] )
  • 12. CHARINDEX ( expressionToFind , expressionToSearch [ , start_location ] ) Data Prep Position Function - CHARINDEX String: This is a great event Parameter Description string Required. The string to extract from start Required. The start position. The first position in string is 1 length Required. The number of characters to extract. Must be a positive number SUBSTRING(string, start, length)
  • 13. Data Prep Position Function PATINDEX PATINDEX ( '%pattern%' , expression ) %pattern% Required. The pattern to find. It MUST be surrounded by %. • % - Match any string of any length (including 0 length) • _ - Match one single character • [] - Match any characters in the brackets, e.g. [xyz] • [^] - Match any character not in the brackets, e.g. [^xyz] • | | string | Required. The string to be searched | Find any string that contain big, and end with driven.org'
  • 14. Data Prep Position Function - TRING_AGG STRING_AGG ( input_string, separator ) [ order_clause ] v input_string is any type that can be converted VARCHAR and NVARCHAR when concatenation. v separator is the separator for the result string. It can be a literal or variable. v order_clause specifies the sort order of concatenated results using WITHIN GROUP clause: WITHIN GROUP ( ORDER BY expression [ ASC | DESC ] )
  • 15. Data Prep Position Function - STRING_SPLIT STRING_SPLIT(string, separator)
  • 16. Analytic • CUME_DIST (Transact-SQL) • FIRST_VALUE (Transact-SQL) • LAG (Transact-SQL) • LAST_VALUE (Transact-SQL) • LEAD (Transact-SQL) • PERCENT_RANK (Transact-SQL) • PERCENTILE_CONT (Transact-SQL) • PERCENTILE_DISC (Transact-SQL) Aggregate • APPROX_COUNT_DISTINCT() • AVG () • CHECKSUM_AGG () • COUNT () • COUNT_BIG () • GROUPING () • GROUPING_ID • MAX () • MIN () • STDEV () • STDEVP () • SUM () • VAR () • VARP () Windowing Function – Framing • Rows/Range • Rows is in memory • Range is in Tempdb • Keywords • Preceding • Following • Unbounded • Current • Ranking • ROW_NUMBER() • RANK() • DENSE_RANK • NTILE SQLAggregate & Analytical Functions
  • 18. Business Request: Provide the Total sales Due, Total Average Sales Orders, Total Number of Sales Orders and Total Sales Rank Orders for each year including all fees (Tax, Shipping, ..). Task: • Get all sales orders for each year • To calculate the • Sum of Total Due by Year. • Total AVG of Sales Orders by Year. • Total Number of Sales Orders by Year. • How well products are selling relative to other years. Hint: Each year --> GROUP BY (AGGREGATE FUNCTIONS)
  • 19. Business Request: RUNNING TOTAL Ø Provide the Daily Running Total Due on Sales Orders and include CustomerID, SalesOrderID, OrderDate for the period of 2014-06-01 onward. Ø Order by SalesOrderID, OrderDate
  • 20. Business Request: The Marketing Team has asked you to return the first three (3) orders, plus the close price, Total Order Due, Total Orders for every customer that purchased more than 15 times from us. Tasks: q Find all orders details per customer q return only the first 3 orders per customer with: ü Close Price ü Total Orders ü where Total Order Counts is greater than 15
  • 21. Business User has asked you to return all orders from the SalesOrderHeader table for any customer who had over $10.000 in purchases for their first three transactions Task: Ø Find the first three orders per customer Ø Aggregate the first three orders Ø Return all orders for those customers Ø Return all customers with over $10.000
  • 22. Business Request: Find the summary of the first and last close price for each day of every months of the year including every single details.
  • 23. Business wants this display To be like this format Calculate the total due for each month, and get the subtotal for each year by region and territory.
  • 24.
  • 25.
  • 26. The Five Major Things To know In RDBMS • CRUD • ACID • TCL • Query Optimizer • When To Use Index Bonus • Exception
  • 27. Key Takeaways Deep understanding of ACID. Master DQL & DML Command. Know when to use TCL Command
  • 28. Feedback Your feedback is important to us. Don’t forget to rate and review the sessions.
  • 29. Jean Joseph Data Engineer/DBA Blog : bigdatadriven.org Email: jean.joseph@bigdatadriven.org Twitter: @garella79/@cloudatadriven Thank You So much For Your Participation!