SlideShare a Scribd company logo
1 of 8
AZURE STREAM ANALYTICS 
ASSIGNMENT 
~ 
Data Management and Business Intelligence - Assignment 3 
Academic Year: ​2018-2019 (Full-Time) 
Assignment Partners:​Baratsas Sotiris (f2821803) ​|​Spanos Nikos (f2821826) 
CONTENTS:
1. Report.pdf ​- A report that summarizes the queries written and their results from the
console
2. queries.sql​- The code for all the queries used in this assignment
3. JSON files - One JSON file for each query, with the outputs from the Live Data
section of Azure Stream. We started the Stream Analytics job for each query, run it
for 4-10 minutes and then extracted the JSON file from the container of BlobStorage
we created.
Query 1
In a tumbling window of 1 minute count the number of Audis that passed through a
toll station.
CODE:
SELECT COUNT([input].[vehicleTypeID]) as Total_Audis
INTO [output]
FROM [input]
INNER JOIN [cars-dataset]
ON [input].[vehicleTypeID] = [cars-dataset].[vehicleTypeID]
WHERE [cars-dataset].[CAR_MAKE]='Audi'
GROUP BY TumblingWindow(minute,1)
OUTPUT:
=========================== END OF QUERY 1 ===========================
Query 2
In a hopping window of 3 minutes, for each color, calculate the total number of cars
that passed through a police speed limit camera. Repeat every 90 seconds.
CODE:
SELECT [colors].[color_name], COUNT([input].[vehicleTypeID]) as Total_Cars
INTO [output]
FROM [input]
INNER JOIN [colors]
ON [input].[colorID]=[colors].[color_code]
WHERE [input].[spotType]='Speed_Limit_Camera'
GROUP BY [colors].[color_name], HoppingWindow(Duration(minute,3) ,
Hop(second,90))
OUTPUT:
=========================== END OF QUERY 2 ===========================
Query 3
In a tumbling window of 20 seconds, for each color, find the oldest car that passed
through a toll station.
CODE:
WITH table1 as
(SELECT [colors].[color_name] as color, [input].[colorID] as colorid,
System.Timestamp t, min([cars-dataset].[CAR_MODEL_YEAR]) as years
FROM [input] TIMESTAMP BY EventEnqueuedUtcTime
INNER JOIN [colors]
ON [input].[colorID] = [colors].[color_code]
INNER JOIN [cars-dataset]
ON [input].[vehicleTypeID] = [cars-dataset].[vehicleTypeID]
WHERE [input].[spotType] = 'Toll_Station'
GROUP BY [colors].[color_name],[input].[colorID], TumblingWindow(second,20))
SELECT table1.color, table1.years, [input].[vehicleTypeID], System.Timestamp
t
INTO [output]
FROM [input] TIMESTAMP BY EventEnqueuedUtcTime
INNER JOIN [cars-dataset]
ON [input].[vehicleTypeID] = [cars-dataset].[vehicleTypeID]
INNER JOIN table1
ON datediff(second, [input], table1) between 0 and 20
AND [input].[colorID] = table1.colorid
AND [cars-dataset].[CAR_MODEL_YEAR] = table1.years
OUTPUT:
=========================== END OF QUERY 3 ===========================
Query 4
In a sliding window of 60 seconds, calculate the speed limit camera spots where the
most violations happened.
CODE:
SELECT COUNT([input].[checkpointID]) as Over_the_speed_limit
INTO [output]
FROM [input]
INNER JOIN [speed-camera-spots]
ON [input].[checkpointID] = [speed-camera-spots].[checkpointID]
WHERE [input].[spotType] = 'Speed_Limit_Camera' AND
CAST([input].[speed] as bigint) > [speed-camera-spots].[SPEED_LIMIT]
GROUP BY SlidingWindow(second, 60)
OUTPUT:
=========================== END OF QUERY 4 ===========================
Query 5
In a sliding window of five minutes, for each color and car model, display the total
number of cars that break the speed limit.
CODE:
SELECT [cars-dataset].[CAR_MODEL], [colors].color_name, COUNT(*)
INTO [output]
FROM [input] TIMESTAMP BY EventEnqueuedUtcTime
INNER JOIN [speed-camera-spots]
ON [input].[checkpointID] = [speed-camera-spots].[checkpointID]
INNER JOIN [cars-dataset]
ON [input].[vehicleTypeID] = [cars-dataset].[vehicleTypeID]
INNER JOIN [colors]
ON [input].[colorID] = [colors].[color_code]
WHERE [input].[spotType] = 'Speed_Limit_Camera'
GROUP BY SlidingWindow(minute,
5),[cars-dataset].[CAR_MODEL],[colors].color_name
OUTPUT:
=========================== END OF QUERY 5 ===========================
Query 6
You have been given a list of the license plates of police’s most wanted criminals. In a
sliding window of 1 minute, display a list of all the cars that you spotted at any
checkpoint.
CODE:
SELECT
COUNT(A.[licensePlate]) as Spotted,
A.[licensePlate] as Wanted_Car,
A.[spotType] as Spot_Type,
A.[checkpointID] as Check_point
INTO [output]
FROM [input] as A
INNER JOIN [wanted-cars] as B
ON A.[licensePlate] = B.[licensePlate]
WHERE A.[licensePlate] = B.[licensePlate]
GROUP BY SlidingWindow(minute, 1), A.[spotType], A.[licensePlate],
A.[checkpointID]
OUTPUT:
Comment:​​Originally there was no wanted car in the data sample, so we put one in manually,
to check if the query works.
=========================== END OF QUERY 6 ===========================
Query 7
In a sliding window of 1 minute, display a list of fake license plates. Check if the same
license plate has passed through any type of checkpoint twice in the same time
window.
CODE:
SELECT
COUNT(ALL [licensePlate]) AS FakeLicense,
[licensePlate] AS LicensePlate,
[checkpointID] AS First_Chechpoint,
LAG([checkpointID]) OVER (PARTITION BY [licensePlate] LIMIT DURATION(minute,
1)) AS Second_Checkpoint
FROM
[input]
WHERE
[checkpointID] <> LAG([checkpointID]) OVER (PARTITION BY [licensePlate] LIMIT
DURATION(minute, 1))
GROUP BY [licensePlate], [checkpointID], SlidingWindow(minute,1),
LAG([checkpointID]) OVER (PARTITION BY [licensePlate] LIMIT DURATION(minute,
1))
OUTPUT:
CODE (2nd Approach):
SELECT
CASE WHEN COUNT(*) = 1 THEN CONCAT([input].[licensePlate], ': 1 time' )
ELSE CONCAT([input].[licensePlate], ': ',CAST(COUNT(*) AS NVARCHAR(MAX)), '
times')
END AS CarsPassed
INTO [output]
FROM [input]
GROUP BY [input].[licensePlate],SlidingWindow(minute, 1)
HAVING COUNT([input].[licensePlate])>1
OUTPUT (2nd Approach):
Comment: ​Originally there was no duplicate car in the data sample, so we put one in
manually, to check if the query works.
=========================== END OF QUERY 7 ===========================
Query 8
In a tumbling window of 2 minutes, calculate the percentage of BMW drivers that
break the speed limit.
CODE:
with Numerator as
(SELECT COUNT([input].[licensePlate]) as up
FROM [input]
INNER JOIN [cars-dataset]
ON [input].[vehicleTypeID]=[cars-dataset].[vehicleTypeID]
INNER JOIN [speed-camera-spots]
ON [input].[checkpointID] = [speed-camera-spots].[checkpointID]
WHERE [cars-dataset].[CAR_MAKE] = 'BMW' AND
CAST([input].[speed] AS bigint)>[speed-camera-spots].[SPEED_LIMIT] AND
[input].[spotType]='Speed_Limit_Camera'
GROUP BY TumblingWindow(minute, 2)),
Denomenator as
(SELECT COUNT([input].[licensePlate]) as down
FROM [input]
INNER JOIN [cars-dataset]
ON [input].[vehicleTypeID]=[cars-dataset].[vehicleTypeID]
WHERE [cars-dataset].[CAR_MAKE] = 'BMW' AND
[input].[spotType]='Speed_Limit_Camera'
GROUP BY TumblingWindow(minute, 2))
select CONCAT('Out of all the BMW drivers that were identified in the last 2
minutes, ',
CEILING((Numerator.up) * 100.0 / Denomenator.down) , '%',' of the drivers
broke the speed limit' ) as Percentage
into [output]
from Numerator
join Denomenator on DATEDIFF(mi, Numerator, Denomenator) BETWEEN 0 AND 2
OUTPUT:
=========================== END OF QUERY 8 ===========================

More Related Content

Similar to Azure Stream Analytics Report - Toll Booth Stream

#include iostream#includectimeusing namespace std;void.docx
#include iostream#includectimeusing namespace std;void.docx#include iostream#includectimeusing namespace std;void.docx
#include iostream#includectimeusing namespace std;void.docxmayank272369
 
PYTHON PROJECT ON CARSHOP SYSTEM
PYTHON PROJECT ON CARSHOP SYSTEMPYTHON PROJECT ON CARSHOP SYSTEM
PYTHON PROJECT ON CARSHOP SYSTEMvikram mahendra
 
The first part of the assignment involves creating very basic GUI co.pdf
The first part of the assignment involves creating very basic GUI co.pdfThe first part of the assignment involves creating very basic GUI co.pdf
The first part of the assignment involves creating very basic GUI co.pdfneerajsachdeva33
 
cbse 12 computer science investigatory project
cbse 12 computer science investigatory project  cbse 12 computer science investigatory project
cbse 12 computer science investigatory project D. j Vicky
 
cbse 12 computer science investigatory project
cbse 12 computer science investigatory project  cbse 12 computer science investigatory project
cbse 12 computer science investigatory project D. j Vicky
 
Mocks Enabling Test-Driven Design
Mocks Enabling Test-Driven DesignMocks Enabling Test-Driven Design
Mocks Enabling Test-Driven DesignAlexandre Martins
 
Workshop: Building a Streaming Data Platform on AWS
Workshop: Building a Streaming Data Platform on AWSWorkshop: Building a Streaming Data Platform on AWS
Workshop: Building a Streaming Data Platform on AWSAmazon Web Services
 
5-minute Practical Streaming Techniques that can Save You Millions
5-minute Practical Streaming Techniques that can Save You Millions5-minute Practical Streaming Techniques that can Save You Millions
5-minute Practical Streaming Techniques that can Save You MillionsHostedbyConfluent
 
Vehicle Parking System Project
Vehicle Parking System ProjectVehicle Parking System Project
Vehicle Parking System ProjectFarooq Mian
 
Cis 115 Education Organization -- snaptutorial.com
Cis 115   Education Organization -- snaptutorial.comCis 115   Education Organization -- snaptutorial.com
Cis 115 Education Organization -- snaptutorial.comDavisMurphyB99
 
Chapter 02 simulation examples
Chapter 02   simulation examplesChapter 02   simulation examples
Chapter 02 simulation examplesImran Ali Chaudhry
 
document.pdf
document.pdfdocument.pdf
document.pdfkavinen
 
Bis 345-final-exam-guide-set-2-new
Bis 345-final-exam-guide-set-2-newBis 345-final-exam-guide-set-2-new
Bis 345-final-exam-guide-set-2-newassignmentcloud85
 
Cis 115 Education Organization / snaptutorial.com
Cis 115 Education Organization / snaptutorial.comCis 115 Education Organization / snaptutorial.com
Cis 115 Education Organization / snaptutorial.comBaileya126
 
CIS 115 Exceptional Education - snaptutorial.com
CIS 115   Exceptional Education - snaptutorial.comCIS 115   Exceptional Education - snaptutorial.com
CIS 115 Exceptional Education - snaptutorial.comDavisMurphyB33
 
Course project for CEE 4674
Course project for CEE 4674Course project for CEE 4674
Course project for CEE 4674Junqi Hu
 

Similar to Azure Stream Analytics Report - Toll Booth Stream (20)

#include iostream#includectimeusing namespace std;void.docx
#include iostream#includectimeusing namespace std;void.docx#include iostream#includectimeusing namespace std;void.docx
#include iostream#includectimeusing namespace std;void.docx
 
PYTHON PROJECT ON CARSHOP SYSTEM
PYTHON PROJECT ON CARSHOP SYSTEMPYTHON PROJECT ON CARSHOP SYSTEM
PYTHON PROJECT ON CARSHOP SYSTEM
 
The first part of the assignment involves creating very basic GUI co.pdf
The first part of the assignment involves creating very basic GUI co.pdfThe first part of the assignment involves creating very basic GUI co.pdf
The first part of the assignment involves creating very basic GUI co.pdf
 
Car Parking System
Car Parking SystemCar Parking System
Car Parking System
 
cbse 12 computer science investigatory project
cbse 12 computer science investigatory project  cbse 12 computer science investigatory project
cbse 12 computer science investigatory project
 
cbse 12 computer science investigatory project
cbse 12 computer science investigatory project  cbse 12 computer science investigatory project
cbse 12 computer science investigatory project
 
Mocks Enabling Test-Driven Design
Mocks Enabling Test-Driven DesignMocks Enabling Test-Driven Design
Mocks Enabling Test-Driven Design
 
Workshop: Building a Streaming Data Platform on AWS
Workshop: Building a Streaming Data Platform on AWSWorkshop: Building a Streaming Data Platform on AWS
Workshop: Building a Streaming Data Platform on AWS
 
Final
FinalFinal
Final
 
5-minute Practical Streaming Techniques that can Save You Millions
5-minute Practical Streaming Techniques that can Save You Millions5-minute Practical Streaming Techniques that can Save You Millions
5-minute Practical Streaming Techniques that can Save You Millions
 
Part4
Part4Part4
Part4
 
Vehicle Parking System Project
Vehicle Parking System ProjectVehicle Parking System Project
Vehicle Parking System Project
 
Cis 115 Education Organization -- snaptutorial.com
Cis 115   Education Organization -- snaptutorial.comCis 115   Education Organization -- snaptutorial.com
Cis 115 Education Organization -- snaptutorial.com
 
Cs practical file
Cs practical fileCs practical file
Cs practical file
 
Chapter 02 simulation examples
Chapter 02   simulation examplesChapter 02   simulation examples
Chapter 02 simulation examples
 
document.pdf
document.pdfdocument.pdf
document.pdf
 
Bis 345-final-exam-guide-set-2-new
Bis 345-final-exam-guide-set-2-newBis 345-final-exam-guide-set-2-new
Bis 345-final-exam-guide-set-2-new
 
Cis 115 Education Organization / snaptutorial.com
Cis 115 Education Organization / snaptutorial.comCis 115 Education Organization / snaptutorial.com
Cis 115 Education Organization / snaptutorial.com
 
CIS 115 Exceptional Education - snaptutorial.com
CIS 115   Exceptional Education - snaptutorial.comCIS 115   Exceptional Education - snaptutorial.com
CIS 115 Exceptional Education - snaptutorial.com
 
Course project for CEE 4674
Course project for CEE 4674Course project for CEE 4674
Course project for CEE 4674
 

More from Sotiris Baratsas

Twitter Mention Graph - Analytics Project
Twitter Mention Graph - Analytics ProjectTwitter Mention Graph - Analytics Project
Twitter Mention Graph - Analytics ProjectSotiris Baratsas
 
Suicides in Greece (vs rest of Europe)
Suicides in Greece (vs rest of Europe)Suicides in Greece (vs rest of Europe)
Suicides in Greece (vs rest of Europe)Sotiris Baratsas
 
Predicting US house prices using Multiple Linear Regression in R
Predicting US house prices using Multiple Linear Regression in RPredicting US house prices using Multiple Linear Regression in R
Predicting US house prices using Multiple Linear Regression in RSotiris Baratsas
 
Brooklyn Property Sales - DATA WAREHOUSE (DW)
Brooklyn Property Sales - DATA WAREHOUSE (DW)Brooklyn Property Sales - DATA WAREHOUSE (DW)
Brooklyn Property Sales - DATA WAREHOUSE (DW)Sotiris Baratsas
 
Predicting Customer Churn in Telecom (Corporate Presentation)
Predicting Customer Churn in Telecom (Corporate Presentation)Predicting Customer Churn in Telecom (Corporate Presentation)
Predicting Customer Churn in Telecom (Corporate Presentation)Sotiris Baratsas
 
Understanding Customer Churn in Telecom - Corporate Presentation
Understanding Customer Churn in Telecom - Corporate PresentationUnderstanding Customer Churn in Telecom - Corporate Presentation
Understanding Customer Churn in Telecom - Corporate PresentationSotiris Baratsas
 
How to Avoid (causing) Death by Powerpoint!
How to Avoid (causing) Death by Powerpoint!How to Avoid (causing) Death by Powerpoint!
How to Avoid (causing) Death by Powerpoint!Sotiris Baratsas
 
The Secrets of the World's Best Presenters
The Secrets of the World's Best PresentersThe Secrets of the World's Best Presenters
The Secrets of the World's Best PresentersSotiris Baratsas
 
The Capitalist's Dilemma - Presentation
The Capitalist's Dilemma - PresentationThe Capitalist's Dilemma - Presentation
The Capitalist's Dilemma - PresentationSotiris Baratsas
 
A behavioral explanation of the DOT COM bubble
A behavioral explanation of the DOT COM bubbleA behavioral explanation of the DOT COM bubble
A behavioral explanation of the DOT COM bubbleSotiris Baratsas
 
[AIESEC] Welcome Week Presentation
[AIESEC] Welcome Week Presentation[AIESEC] Welcome Week Presentation
[AIESEC] Welcome Week PresentationSotiris Baratsas
 
Advanced Feedback Methodologies
Advanced Feedback MethodologiesAdvanced Feedback Methodologies
Advanced Feedback MethodologiesSotiris Baratsas
 
Advanced University Relations [AIESEC Training]
Advanced University Relations [AIESEC Training]Advanced University Relations [AIESEC Training]
Advanced University Relations [AIESEC Training]Sotiris Baratsas
 
How to organize massive EwA Events [AIESEC Training]
How to organize massive EwA Events [AIESEC Training]How to organize massive EwA Events [AIESEC Training]
How to organize massive EwA Events [AIESEC Training]Sotiris Baratsas
 
How to run effective Social Media Campaigns [AIESEC Training]
How to run effective Social Media Campaigns [AIESEC Training]How to run effective Social Media Campaigns [AIESEC Training]
How to run effective Social Media Campaigns [AIESEC Training]Sotiris Baratsas
 
Global Youth to Business Forum Sponsorship Package
Global Youth to Business Forum Sponsorship PackageGlobal Youth to Business Forum Sponsorship Package
Global Youth to Business Forum Sponsorship PackageSotiris Baratsas
 
Online Marketing - STEP IT UP
Online Marketing - STEP IT UPOnline Marketing - STEP IT UP
Online Marketing - STEP IT UPSotiris Baratsas
 
Ready, Set, Go Global (Opening & Closing)
Ready, Set, Go Global (Opening & Closing)Ready, Set, Go Global (Opening & Closing)
Ready, Set, Go Global (Opening & Closing)Sotiris Baratsas
 
Tomorrowland - Induction Seminar Session
Tomorrowland - Induction Seminar SessionTomorrowland - Induction Seminar Session
Tomorrowland - Induction Seminar SessionSotiris Baratsas
 

More from Sotiris Baratsas (20)

Twitter Mention Graph - Analytics Project
Twitter Mention Graph - Analytics ProjectTwitter Mention Graph - Analytics Project
Twitter Mention Graph - Analytics Project
 
Suicides in Greece (vs rest of Europe)
Suicides in Greece (vs rest of Europe)Suicides in Greece (vs rest of Europe)
Suicides in Greece (vs rest of Europe)
 
Predicting US house prices using Multiple Linear Regression in R
Predicting US house prices using Multiple Linear Regression in RPredicting US house prices using Multiple Linear Regression in R
Predicting US house prices using Multiple Linear Regression in R
 
Brooklyn Property Sales - DATA WAREHOUSE (DW)
Brooklyn Property Sales - DATA WAREHOUSE (DW)Brooklyn Property Sales - DATA WAREHOUSE (DW)
Brooklyn Property Sales - DATA WAREHOUSE (DW)
 
Predicting Customer Churn in Telecom (Corporate Presentation)
Predicting Customer Churn in Telecom (Corporate Presentation)Predicting Customer Churn in Telecom (Corporate Presentation)
Predicting Customer Churn in Telecom (Corporate Presentation)
 
Understanding Customer Churn in Telecom - Corporate Presentation
Understanding Customer Churn in Telecom - Corporate PresentationUnderstanding Customer Churn in Telecom - Corporate Presentation
Understanding Customer Churn in Telecom - Corporate Presentation
 
How to Avoid (causing) Death by Powerpoint!
How to Avoid (causing) Death by Powerpoint!How to Avoid (causing) Death by Powerpoint!
How to Avoid (causing) Death by Powerpoint!
 
The Secrets of the World's Best Presenters
The Secrets of the World's Best PresentersThe Secrets of the World's Best Presenters
The Secrets of the World's Best Presenters
 
The Capitalist's Dilemma - Presentation
The Capitalist's Dilemma - PresentationThe Capitalist's Dilemma - Presentation
The Capitalist's Dilemma - Presentation
 
Why Global Talent
Why Global TalentWhy Global Talent
Why Global Talent
 
A behavioral explanation of the DOT COM bubble
A behavioral explanation of the DOT COM bubbleA behavioral explanation of the DOT COM bubble
A behavioral explanation of the DOT COM bubble
 
[AIESEC] Welcome Week Presentation
[AIESEC] Welcome Week Presentation[AIESEC] Welcome Week Presentation
[AIESEC] Welcome Week Presentation
 
Advanced Feedback Methodologies
Advanced Feedback MethodologiesAdvanced Feedback Methodologies
Advanced Feedback Methodologies
 
Advanced University Relations [AIESEC Training]
Advanced University Relations [AIESEC Training]Advanced University Relations [AIESEC Training]
Advanced University Relations [AIESEC Training]
 
How to organize massive EwA Events [AIESEC Training]
How to organize massive EwA Events [AIESEC Training]How to organize massive EwA Events [AIESEC Training]
How to organize massive EwA Events [AIESEC Training]
 
How to run effective Social Media Campaigns [AIESEC Training]
How to run effective Social Media Campaigns [AIESEC Training]How to run effective Social Media Campaigns [AIESEC Training]
How to run effective Social Media Campaigns [AIESEC Training]
 
Global Youth to Business Forum Sponsorship Package
Global Youth to Business Forum Sponsorship PackageGlobal Youth to Business Forum Sponsorship Package
Global Youth to Business Forum Sponsorship Package
 
Online Marketing - STEP IT UP
Online Marketing - STEP IT UPOnline Marketing - STEP IT UP
Online Marketing - STEP IT UP
 
Ready, Set, Go Global (Opening & Closing)
Ready, Set, Go Global (Opening & Closing)Ready, Set, Go Global (Opening & Closing)
Ready, Set, Go Global (Opening & Closing)
 
Tomorrowland - Induction Seminar Session
Tomorrowland - Induction Seminar SessionTomorrowland - Induction Seminar Session
Tomorrowland - Induction Seminar Session
 

Recently uploaded

DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfJohn Sterrett
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Cantervoginip
 
RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.natarajan8993
 
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdfPredicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdfBoston Institute of Analytics
 
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...Boston Institute of Analytics
 
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degreeyuu sss
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort servicejennyeacort
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPTBoston Institute of Analytics
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一F sss
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPramod Kumar Srivastava
 
Call Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceCall Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceSapana Sha
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...dajasot375
 
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改yuu sss
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptxthyngster
 
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhijennyeacort
 
Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Colleen Farrelly
 
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024thyngster
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 217djon017
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfSocial Samosa
 

Recently uploaded (20)

DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdf
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Canter
 
RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.
 
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdfPredicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
 
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
 
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
 
Call Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort ServiceCall Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort Service
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
 
Call Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceCall Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts Service
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
 
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
 
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
 
Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024
 
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
 

Azure Stream Analytics Report - Toll Booth Stream

  • 1. AZURE STREAM ANALYTICS  ASSIGNMENT  ~  Data Management and Business Intelligence - Assignment 3  Academic Year: ​2018-2019 (Full-Time)  Assignment Partners:​Baratsas Sotiris (f2821803) ​|​Spanos Nikos (f2821826)  CONTENTS: 1. Report.pdf ​- A report that summarizes the queries written and their results from the console 2. queries.sql​- The code for all the queries used in this assignment 3. JSON files - One JSON file for each query, with the outputs from the Live Data section of Azure Stream. We started the Stream Analytics job for each query, run it for 4-10 minutes and then extracted the JSON file from the container of BlobStorage we created. Query 1 In a tumbling window of 1 minute count the number of Audis that passed through a toll station. CODE: SELECT COUNT([input].[vehicleTypeID]) as Total_Audis INTO [output] FROM [input] INNER JOIN [cars-dataset] ON [input].[vehicleTypeID] = [cars-dataset].[vehicleTypeID] WHERE [cars-dataset].[CAR_MAKE]='Audi' GROUP BY TumblingWindow(minute,1) OUTPUT: =========================== END OF QUERY 1 ===========================
  • 2. Query 2 In a hopping window of 3 minutes, for each color, calculate the total number of cars that passed through a police speed limit camera. Repeat every 90 seconds. CODE: SELECT [colors].[color_name], COUNT([input].[vehicleTypeID]) as Total_Cars INTO [output] FROM [input] INNER JOIN [colors] ON [input].[colorID]=[colors].[color_code] WHERE [input].[spotType]='Speed_Limit_Camera' GROUP BY [colors].[color_name], HoppingWindow(Duration(minute,3) , Hop(second,90)) OUTPUT: =========================== END OF QUERY 2 ===========================
  • 3. Query 3 In a tumbling window of 20 seconds, for each color, find the oldest car that passed through a toll station. CODE: WITH table1 as (SELECT [colors].[color_name] as color, [input].[colorID] as colorid, System.Timestamp t, min([cars-dataset].[CAR_MODEL_YEAR]) as years FROM [input] TIMESTAMP BY EventEnqueuedUtcTime INNER JOIN [colors] ON [input].[colorID] = [colors].[color_code] INNER JOIN [cars-dataset] ON [input].[vehicleTypeID] = [cars-dataset].[vehicleTypeID] WHERE [input].[spotType] = 'Toll_Station' GROUP BY [colors].[color_name],[input].[colorID], TumblingWindow(second,20)) SELECT table1.color, table1.years, [input].[vehicleTypeID], System.Timestamp t INTO [output] FROM [input] TIMESTAMP BY EventEnqueuedUtcTime INNER JOIN [cars-dataset] ON [input].[vehicleTypeID] = [cars-dataset].[vehicleTypeID] INNER JOIN table1 ON datediff(second, [input], table1) between 0 and 20 AND [input].[colorID] = table1.colorid AND [cars-dataset].[CAR_MODEL_YEAR] = table1.years OUTPUT: =========================== END OF QUERY 3 ===========================
  • 4. Query 4 In a sliding window of 60 seconds, calculate the speed limit camera spots where the most violations happened. CODE: SELECT COUNT([input].[checkpointID]) as Over_the_speed_limit INTO [output] FROM [input] INNER JOIN [speed-camera-spots] ON [input].[checkpointID] = [speed-camera-spots].[checkpointID] WHERE [input].[spotType] = 'Speed_Limit_Camera' AND CAST([input].[speed] as bigint) > [speed-camera-spots].[SPEED_LIMIT] GROUP BY SlidingWindow(second, 60) OUTPUT: =========================== END OF QUERY 4 =========================== Query 5 In a sliding window of five minutes, for each color and car model, display the total number of cars that break the speed limit. CODE: SELECT [cars-dataset].[CAR_MODEL], [colors].color_name, COUNT(*) INTO [output] FROM [input] TIMESTAMP BY EventEnqueuedUtcTime INNER JOIN [speed-camera-spots] ON [input].[checkpointID] = [speed-camera-spots].[checkpointID] INNER JOIN [cars-dataset] ON [input].[vehicleTypeID] = [cars-dataset].[vehicleTypeID] INNER JOIN [colors] ON [input].[colorID] = [colors].[color_code] WHERE [input].[spotType] = 'Speed_Limit_Camera'
  • 5. GROUP BY SlidingWindow(minute, 5),[cars-dataset].[CAR_MODEL],[colors].color_name OUTPUT: =========================== END OF QUERY 5 =========================== Query 6 You have been given a list of the license plates of police’s most wanted criminals. In a sliding window of 1 minute, display a list of all the cars that you spotted at any checkpoint. CODE: SELECT COUNT(A.[licensePlate]) as Spotted, A.[licensePlate] as Wanted_Car, A.[spotType] as Spot_Type, A.[checkpointID] as Check_point INTO [output] FROM [input] as A INNER JOIN [wanted-cars] as B ON A.[licensePlate] = B.[licensePlate] WHERE A.[licensePlate] = B.[licensePlate] GROUP BY SlidingWindow(minute, 1), A.[spotType], A.[licensePlate], A.[checkpointID] OUTPUT:
  • 6. Comment:​​Originally there was no wanted car in the data sample, so we put one in manually, to check if the query works. =========================== END OF QUERY 6 =========================== Query 7 In a sliding window of 1 minute, display a list of fake license plates. Check if the same license plate has passed through any type of checkpoint twice in the same time window. CODE: SELECT COUNT(ALL [licensePlate]) AS FakeLicense, [licensePlate] AS LicensePlate, [checkpointID] AS First_Chechpoint, LAG([checkpointID]) OVER (PARTITION BY [licensePlate] LIMIT DURATION(minute, 1)) AS Second_Checkpoint FROM [input] WHERE [checkpointID] <> LAG([checkpointID]) OVER (PARTITION BY [licensePlate] LIMIT DURATION(minute, 1)) GROUP BY [licensePlate], [checkpointID], SlidingWindow(minute,1), LAG([checkpointID]) OVER (PARTITION BY [licensePlate] LIMIT DURATION(minute, 1)) OUTPUT:
  • 7. CODE (2nd Approach): SELECT CASE WHEN COUNT(*) = 1 THEN CONCAT([input].[licensePlate], ': 1 time' ) ELSE CONCAT([input].[licensePlate], ': ',CAST(COUNT(*) AS NVARCHAR(MAX)), ' times') END AS CarsPassed INTO [output] FROM [input] GROUP BY [input].[licensePlate],SlidingWindow(minute, 1) HAVING COUNT([input].[licensePlate])>1 OUTPUT (2nd Approach): Comment: ​Originally there was no duplicate car in the data sample, so we put one in manually, to check if the query works. =========================== END OF QUERY 7 =========================== Query 8 In a tumbling window of 2 minutes, calculate the percentage of BMW drivers that break the speed limit. CODE:
  • 8. with Numerator as (SELECT COUNT([input].[licensePlate]) as up FROM [input] INNER JOIN [cars-dataset] ON [input].[vehicleTypeID]=[cars-dataset].[vehicleTypeID] INNER JOIN [speed-camera-spots] ON [input].[checkpointID] = [speed-camera-spots].[checkpointID] WHERE [cars-dataset].[CAR_MAKE] = 'BMW' AND CAST([input].[speed] AS bigint)>[speed-camera-spots].[SPEED_LIMIT] AND [input].[spotType]='Speed_Limit_Camera' GROUP BY TumblingWindow(minute, 2)), Denomenator as (SELECT COUNT([input].[licensePlate]) as down FROM [input] INNER JOIN [cars-dataset] ON [input].[vehicleTypeID]=[cars-dataset].[vehicleTypeID] WHERE [cars-dataset].[CAR_MAKE] = 'BMW' AND [input].[spotType]='Speed_Limit_Camera' GROUP BY TumblingWindow(minute, 2)) select CONCAT('Out of all the BMW drivers that were identified in the last 2 minutes, ', CEILING((Numerator.up) * 100.0 / Denomenator.down) , '%',' of the drivers broke the speed limit' ) as Percentage into [output] from Numerator join Denomenator on DATEDIFF(mi, Numerator, Denomenator) BETWEEN 0 AND 2 OUTPUT: =========================== END OF QUERY 8 ===========================